Skip to content

Commit 3d88b3e

Browse files
committed
Release 3.1
0 parents  commit 3d88b3e

File tree

12 files changed

+1602
-0
lines changed

12 files changed

+1602
-0
lines changed
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
name: Test Coverage
2+
3+
on: [push]
4+
5+
jobs:
6+
build:
7+
runs-on: windows-latest
8+
9+
steps:
10+
- name: Checkout repository
11+
uses: actions/checkout@v2
12+
13+
- name: Setup Python
14+
uses: actions/setup-python@v2
15+
with:
16+
python-version: 3.x
17+
18+
- name: Install dependencies
19+
run: |
20+
pip install setuptools pytest-cov
21+
git clone https://github.com/${{ github.repository_owner }}/${{ github.event.repository.name }}
22+
cd ${{ github.event.repository.name }}/Files
23+
python setup.py install
24+
25+
- name: Run tests and generate coverage report
26+
run: |
27+
cd Files/tests
28+
coverage run -m unittest unit.py
29+
coverage report
30+
coverage xml -o coverage.xml
31+
32+
- name: Upload artifacts
33+
uses: actions/upload-artifact@v2
34+
with:
35+
name: unit-test
36+
path: Files/tests/coverage.xml
37+
38+
send:
39+
runs-on: ubuntu-latest
40+
needs: build
41+
42+
steps:
43+
- name: Retrieve coverage
44+
uses: actions/download-artifact@v2
45+
46+
- name: Coverage reporter
47+
uses: codacy/codacy-coverage-reporter-action@v1.3.0
48+
with:
49+
project-token: ${{ secrets.CODACY_PROJECT_TOKEN }}
50+
coverage-reports: unit-test/coverage.xml

Documents/ChangeLog.md

Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
## 3.1
2+
### Added ➕
3+
- Command-line console script support.
4+
- Exceptions from incorrect dates ranges.
5+
### Fixed 📝
6+
- Issue leading to macOS files not having creation time set.
7+
- `utils.set_from.file_name` exception handling.
8+
- Issue causing microseconds not being retrieved.
9+
10+
## 3.0
11+
### Added ➕
12+
- Editable properties.
13+
### Modified 🔁
14+
- Program files structure.
15+
- Improved documentation.
16+
- Path system.
17+
### Fixed 📝
18+
- Issue leading to Windows directories not having creation time set.
19+
20+
## 2.0
21+
### Added ➕
22+
- `Batch` alias for `Utils.Keep`
23+
- Support for setting dates to directories.
24+
- Support for copying dates to directories.
25+
### Modified 🔁
26+
- Program files structure.
27+
- `File` file path system.
28+
### Fixed 📝
29+
- Bugs.
30+
### Removed 🚫
31+
- `Utils.Swap`
32+
- `fromfn` alias from `Utils.fromname`
33+
- `Utils.fromfile` to `Utils.Name`
34+
35+
## 1.8
36+
### Added ➕
37+
- `Utils.fromfile`
38+
39+
## 1.7
40+
### Fixed 📝
41+
- Bugs.
42+
43+
## 1.6
44+
### Added ➕
45+
- `Utils.Swap`
46+
### Fixed 📝
47+
- Bugs.
48+
49+
## 1.5
50+
### Fixed 📝
51+
- Bugs.
52+
53+
## 1.4
54+
### Added ➕
55+
- `Utils.copy`
56+
### Fixed 📝
57+
- Bugs.
58+
59+
## 1.3
60+
### Modified 🔁
61+
- Renamed:
62+
- `FileDate` to `File`
63+
- `Utils.release` to `Utils.drop`
64+
- Reduced code size.
65+
66+
## 1.2
67+
### Fixed 📝
68+
- Code refraction.
69+
- Bugs.
70+
71+
## 1.1
72+
### Modified 🔁
73+
- Code structure.
74+
75+
## 1.0
76+
- Initial release.

Documents/Pictures/filedate.svg

Lines changed: 1 addition & 0 deletions
Loading

Files/setup.py

Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
import os
2+
from shutil import rmtree
3+
from setuptools import setup, find_packages
4+
5+
# Remove directories after installing
6+
cleanup = True
7+
8+
#-=-=-=-#
9+
10+
__title__ = os.path.basename(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
11+
12+
#-=-=-=-#
13+
14+
# Cleanup
15+
if cleanup:
16+
if "install" in os.sys.argv:
17+
18+
# Built directories
19+
dirs = [
20+
"build", "dist", "name",
21+
f"{__title__}.egg-info"
22+
]
23+
24+
for directory in dirs:
25+
rmtree(directory, True)
26+
27+
directory = "src"
28+
if os.path.exists(directory):
29+
os.rename(directory, __title__)
30+
31+
#-=-=-=-#
32+
33+
tags = [__title__, "file", "date", "change", "changing", "changer"]
34+
35+
setup(
36+
name = __title__,
37+
version = "3.1",
38+
author = "kubinka0505",
39+
url = f"https://github.com/kubinka0505/{__title__}",
40+
keywords = tags,
41+
classifiers = [
42+
"Development Status :: 6 - Mature",
43+
"Environment :: Console",
44+
"Intended Audience :: Developers",
45+
"Intended Audience :: End Users/Desktop",
46+
"Intended Audience :: System Administrators",
47+
"License :: OSI Approved :: GNU General Public License v3 (GPLv3)",
48+
"Natural Language :: English",
49+
"Operating System :: OS Independent",
50+
"Programming Language :: Python :: 3 :: Only",
51+
"Topic :: Desktop Environment :: File Managers",
52+
],
53+
python_requires = ">=3.4",
54+
install_requires = [
55+
"python-dateutil",
56+
],
57+
entry_points={
58+
"console_scripts": [
59+
"filedate = filedate.cli_core:main",
60+
]
61+
},
62+
packages = find_packages()
63+
)
64+
65+
#-=-=-=-#
66+
67+
if os.path.exists(__title__):
68+
os.rename(__title__, directory)

Files/src/__init__.py

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
"""Simple, convenient and cross-platform file date changing library."""
2+
3+
__author__ = "kubinka0505"
4+
__credits__ = __author__
5+
__version__ = "3.1"
6+
__date__ = "10th February 2024"
7+
8+
#-=-=-=-#
9+
10+
from .config import *
11+
from .core import *
12+
from .utils import *
13+
14+
#-=-=-=-#
15+
16+
if is_win:
17+
del byref, windll
18+
19+
del is_win, is_mac, platform

Files/src/cli_core.py

Lines changed: 112 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,112 @@
1+
import filedate
2+
from argparse import ArgumentParser
3+
4+
Parser = ArgumentParser(
5+
prog = "filedate",
6+
description = "Command-line wrapper for `filedate.core` module.",
7+
epilog = "If no argument is specified, `File.get` function is called, otherwise `File.set`",
8+
add_help = 0,
9+
allow_abbrev = 0
10+
)
11+
12+
#-=-=-=-#
13+
# Groups
14+
15+
Required = Parser.add_argument_group("Required arguments")
16+
Optional = Parser.add_argument_group("Optional arguments")
17+
Switch = Parser.add_argument_group("Switch arguments")
18+
19+
#-=-=-=-#
20+
# Arguments
21+
22+
Required.add_argument(
23+
"-i", "--inputs",
24+
nargs = "*",
25+
type = str,
26+
required = True,
27+
help = "Existing files absolute path."
28+
)
29+
30+
#---#
31+
32+
Optional.add_argument(
33+
"-c", "--created",
34+
default = "",
35+
help = "Date of files creation. Does nothing on non-Windows operating systems."
36+
)
37+
Optional.add_argument(
38+
"-m", "--modified",
39+
default = "",
40+
help = "Date of files modification date."
41+
)
42+
Optional.add_argument(
43+
"-a", "--accessed",
44+
default = "",
45+
help = "Date of files access date."
46+
)
47+
48+
#---#
49+
50+
Switch.add_argument(
51+
"-e", "--expanded",
52+
action = "store_false",
53+
help = "Outputs more precise `datetime.datetime.strftime` format argument pattern."
54+
)
55+
56+
Switch.add_argument(
57+
"-h", "--help",
58+
action = "help",
59+
help = "Shows this message."
60+
)
61+
62+
#-=-=-=-#
63+
# Settings
64+
65+
args = Parser.parse_args()
66+
67+
if args.expanded:
68+
args.format_string = "%d/%m/%Y %H:%M:%S"
69+
else:
70+
args.format_string = "%A, %d{} %B %Y, %H:%M:%S.%f"
71+
72+
#-=-=-=-#
73+
# Functions
74+
75+
def main():
76+
for Input in args.inputs:
77+
input_obj = filedate.File(Input)
78+
_get = input_obj.get()
79+
80+
if not any((args.created, args.modified, args.accessed)):
81+
longest = [k for k in _get.keys()]
82+
longest = sorted(longest, key = len)[-1]
83+
longest = len(longest)
84+
85+
print(input_obj.path)
86+
for key, value in _get.items():
87+
ordinal = "th"
88+
89+
# Ordinals for "--expanded"
90+
if value.day % 10 == 1:
91+
ordinal = "st"
92+
93+
if value.day % 10 == 2:
94+
ordinal = "nd"
95+
96+
if value.day % 10 == 3:
97+
ordinal = "rd"
98+
99+
args.format_string = args.format_string.format(ordinal)
100+
101+
print(
102+
4 * " " + (key.title() + ":").ljust(longest + 1, " "), value.strftime(args.format_string),
103+
)
104+
105+
if Input != args.inputs[-1]:
106+
print()
107+
else:
108+
input_obj.set(
109+
created = args.created if args.created else None,
110+
modified = args.modified if args.modified else None,
111+
accessed = args.accessed if args.accessed else None
112+
)

Files/src/config.py

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
"""Module configuration classes and variables."""
2+
3+
import os
4+
5+
platform = os.sys.platform.lower()
6+
7+
is_win = platform.startswith("win")
8+
is_mac = platform.startswith("darwin")
9+
10+
#-=-=-=-=-=-#
11+
12+
class exceptions:
13+
SYSTEM = OSError
14+
15+
class date:
16+
WRONG = ValueError("One of the dates could not be converted to a date object")
17+
RANGE_TIMESTAMP_SET = ValueError("Cannot use this `datetime.datetime` object to set the date, as its `timestamp` bound method call fails")
18+
RANGE_DATETIME_SET = ValueError("Cannot set the date not being in the `datetime.datetime` values range")
19+
20+
class path:
21+
NOT_FOUND = FileNotFoundError('File was not found ("{file_path}")')
22+
NO_DATE = ValueError('No date was detected in the parsed path string ("{string}")')

0 commit comments

Comments
 (0)