-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
172 additions
and
222 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,47 +1,55 @@ | ||
import datetime | ||
import os | ||
import git | ||
|
||
number = None | ||
|
||
def next_number(path): | ||
global number | ||
max_num = 0 | ||
for file in os.listdir(path): | ||
if "_" in file: file = file.split("_")[0] | ||
try: | ||
if int(file) > max_num: max_num = int(file) | ||
except: pass | ||
number = max_num + 1 | ||
return number | ||
|
||
def new(name = None): | ||
global number | ||
|
||
timestamp = str(datetime.datetime.now()).split(" ") | ||
|
||
try: | ||
repo = git.Repo(search_parent_directories=True) | ||
sha = "_" + repo.head.object.hexsha[:7] | ||
except: sha = "" | ||
|
||
path = "./archives/" + timestamp[0] + sha | ||
|
||
if not os.path.isdir(path): os.makedirs(path) | ||
|
||
if path is not None: next_number(path) | ||
else: number = 1 | ||
|
||
if name is not None: name = "_" + name | ||
|
||
if not os.path.isdir(f"{path}/{number}{name}"): os.makedirs(f"{path}/{number}{name}") | ||
|
||
|
||
return f"{path}/{number}{name}" | ||
|
||
def description(**kwargs): | ||
desc = "" | ||
for key,value in kwargs.items(): | ||
if type(value) in [int, str, float, bool] : desc += f",{key}={value}" | ||
else: print(f"⚠️ Your archive description contain a non-supported type: {type(value)}") | ||
return desc[1:] | ||
import datetime | ||
import os | ||
import git | ||
|
||
number = None | ||
|
||
def next_number(path): | ||
global number | ||
max_num = 0 | ||
for file in os.listdir(path): | ||
if "_" in file: file = file.split("_")[0] | ||
try: | ||
if int(file) > max_num: max_num = int(file) | ||
except: pass | ||
number = max_num + 1 | ||
return number | ||
|
||
def new(name = None, verbose=False, **kwargs): | ||
global number | ||
|
||
if kwargs: | ||
name = name + "-" + description(**kwargs) | ||
|
||
timestamp = str(datetime.datetime.now()).split(" ") | ||
|
||
try: | ||
repo = git.Repo(search_parent_directories=True) | ||
sha = "_" + repo.head.object.hexsha[:7] | ||
except: sha = "" | ||
|
||
path = "./archives/" + timestamp[0] + sha | ||
|
||
if not os.path.isdir(path): os.makedirs(path) | ||
|
||
if path is not None: next_number(path) | ||
else: number = 1 | ||
|
||
if name is not None: name = "_" + name | ||
else: name = "" | ||
|
||
if not os.path.isdir(f"{path}/{number}{name}"): os.makedirs(f"{path}/{number}{name}") | ||
|
||
archive_name = f"{path}/{number}{name}" | ||
|
||
if verbose: | ||
print(f"Archive created at {archive_name}") | ||
|
||
return archive_name | ||
|
||
def description(**kwargs): | ||
desc = "" | ||
for key,value in kwargs.items(): | ||
if type(value) in [int, str, float, bool] : desc += f",{key}={value}" | ||
else: print(f"⚠️ Your archive description contain a non-supported type: {type(value)}") | ||
return desc[1:] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,22 +1,30 @@ | ||
# 0.0.11 | ||
|
||
> **Warning** | ||
> | ||
> This update include breaking changes 💥 | ||
## 📢 Announcements | ||
- This module is now available on Pypi! | ||
https://pypi.org/project/LRFutils/0.0.11/ | ||
- You can then install it using `pip install LRFutils` | ||
|
||
## ➕ Additions | ||
- Added `average_ETA` parameter on progress bar to prevent variating ETA. By default, this parameter is set to 10 | ||
|
||
## 🔧 Tweaks | ||
- 💥 `LRFutils.progress.Bar()`'s `duration` parameter was renamed in `show_duration` to be more explicit. | ||
- 💥 `LRFutils.log` module was renamed `LRFutils.logs` in order to have a conveniant import line (`from LRFutils import logs`) while avoiding conflict with mathematical log function. | ||
- 💥 `LRFutils.color.Color` class, was removed. All the attribute are now directly in the module `LRFutils.color` (which allow to import the module on the same line than other ones `from LRFutils import color, logs, archive [...]`) | ||
|
||
# 0.0.10 | ||
|
||
# 0.0.12 | ||
|
||
## 🩹 Fixes | ||
- Fixed `LRFutils.archive.new()` without name leanding to "None" in the archive name. | ||
|
||
## 🔧 Tweaks | ||
- Now, if any other parameter than `name` or `verbose` is given to the `LRFutils.archive.ew()` function, this parameter will be added to the name using `LRFutils.archive.description()` method. | ||
|
||
# 0.0.11 | ||
|
||
> **Warning** | ||
> | ||
> This update include breaking changes 💥 | ||
## 📢 Announcements | ||
- This module is now available on Pypi! | ||
https://pypi.org/project/LRFutils/0.0.11/ | ||
- You can then install it using `pip install LRFutils` | ||
|
||
## ➕ Additions | ||
- Added `average_ETA` parameter on progress bar to prevent variating ETA. By default, this parameter is set to 10 | ||
|
||
## 🔧 Tweaks | ||
- 💥 `LRFutils.progress.Bar()`'s `duration` parameter was renamed in `show_duration` to be more explicit. | ||
- 💥 `LRFutils.log` module was renamed `LRFutils.logs` in order to have a conveniant import line (`from LRFutils import logs`) while avoiding conflict with mathematical log function. | ||
- 💥 `LRFutils.color.Color` class, was removed. All the attribute are now directly in the module `LRFutils.color` (which allow to import the module on the same line than other ones `from LRFutils import color, logs, archive [...]`) | ||
|
||
# 0.0.10 | ||
|
||
> 🔎 Changelog doesn't go that far... |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
{ | ||
"cells": [ | ||
{ | ||
"cell_type": "markdown", | ||
"metadata": {}, | ||
"source": [ | ||
"# 🗃️ Archive" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": 1, | ||
"metadata": {}, | ||
"outputs": [ | ||
{ | ||
"name": "stdout", | ||
"output_type": "stream", | ||
"text": [ | ||
"Archive created at ./archives/2022-10-22_14298e9/1_My archive-p1=3.14,p2=42,p3=hello\n" | ||
] | ||
} | ||
], | ||
"source": [ | ||
"from LRFutils import archive\n", | ||
"\n", | ||
"parameter_1 = 3.14\n", | ||
"parameter_2 = 42\n", | ||
"parameter_3 = \"hello\"\n", | ||
"\n", | ||
"path = archive.new(\"My_archive\", verbose=True, p1=parameter_1, p2=parameter_2, p3=parameter_3)" | ||
] | ||
} | ||
], | ||
"metadata": { | ||
"kernelspec": { | ||
"display_name": "Python 3.10.8 64-bit", | ||
"language": "python", | ||
"name": "python3" | ||
}, | ||
"language_info": { | ||
"codemirror_mode": { | ||
"name": "ipython", | ||
"version": 3 | ||
}, | ||
"file_extension": ".py", | ||
"mimetype": "text/x-python", | ||
"name": "python", | ||
"nbconvert_exporter": "python", | ||
"pygments_lexer": "ipython3", | ||
"version": "3.10.8" | ||
}, | ||
"orig_nbformat": 4, | ||
"vscode": { | ||
"interpreter": { | ||
"hash": "97cc609b13305c559618ec78a438abc56230b9381f827f22d070313b9a1f3777" | ||
} | ||
} | ||
}, | ||
"nbformat": 4, | ||
"nbformat_minor": 2 | ||
} |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,23 +1,23 @@ | ||
from setuptools import setup | ||
|
||
requirements = [] | ||
with open('requirements.txt') as f: | ||
requirements = f.read().splitlines() | ||
|
||
setup( | ||
name="LRFutils", | ||
version = "0.0.11", | ||
description = 'Just a custom library to share with some colleagues. Use it at your own risks.', | ||
author = 'Leirof', | ||
author_email = 'vince.lrf@gmail.com', | ||
url = 'https://github.com/LeiRoF/Utils', | ||
packages=['LRFutils'], | ||
install_requires=requirements, | ||
python_requires='>=3.10.0', | ||
classifiers=[ | ||
"Programming Language :: Python :: 3", | ||
"License :: OSI Approved :: MIT License", | ||
"Operating System :: OS Independent", | ||
'Intended Audience :: Developers' | ||
] | ||
from setuptools import setup | ||
|
||
requirements = [] | ||
with open('requirements.txt') as f: | ||
requirements = f.read().splitlines() | ||
|
||
setup( | ||
name="LRFutils", | ||
version = "0.0.12", | ||
description = 'Just a custom library to share with some colleagues. Use it at your own risks.', | ||
author = 'Leirof', | ||
author_email = 'vince.lrf@gmail.com', | ||
url = 'https://github.com/LeiRoF/Utils', | ||
packages=['LRFutils'], | ||
install_requires=requirements, | ||
python_requires='>=3.10.0', | ||
classifiers=[ | ||
"Programming Language :: Python :: 3", | ||
"License :: OSI Approved :: MIT License", | ||
"Operating System :: OS Independent", | ||
'Intended Audience :: Developers' | ||
] | ||
) |
Oops, something went wrong.