Skip to content

Commit d6029fb

Browse files
committed
Release 3.1
0 parents  commit d6029fb

24 files changed

+2303
-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/build/lib/filedate/__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/build/lib/filedate/cli_core.py

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

Files/build/lib/filedate/config.py

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

0 commit comments

Comments
 (0)