Skip to content

Commit

Permalink
Release 3.1
Browse files Browse the repository at this point in the history
  • Loading branch information
kubinka0505 committed Dec 12, 2024
0 parents commit d6029fb
Show file tree
Hide file tree
Showing 24 changed files with 2,303 additions and 0 deletions.
50 changes: 50 additions & 0 deletions .github/workflows/coverage_test_unit.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
name: Test Coverage

on: [push]

jobs:
build:
runs-on: windows-latest

steps:
- name: Checkout repository
uses: actions/checkout@v2

- name: Setup Python
uses: actions/setup-python@v2
with:
python-version: 3.x

- name: Install dependencies
run: |
pip install setuptools pytest-cov
git clone https://github.com/${{ github.repository_owner }}/${{ github.event.repository.name }}
cd ${{ github.event.repository.name }}/Files
python setup.py install
- name: Run tests and generate coverage report
run: |
cd Files/tests
coverage run -m unittest unit.py
coverage report
coverage xml -o coverage.xml
- name: Upload artifacts
uses: actions/upload-artifact@v2
with:
name: unit-test
path: Files/tests/coverage.xml

send:
runs-on: ubuntu-latest
needs: build

steps:
- name: Retrieve coverage
uses: actions/download-artifact@v2

- name: Coverage reporter
uses: codacy/codacy-coverage-reporter-action@v1.3.0
with:
project-token: ${{ secrets.CODACY_PROJECT_TOKEN }}
coverage-reports: unit-test/coverage.xml
76 changes: 76 additions & 0 deletions Documents/ChangeLog.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
## 3.1
### Added ➕
- Command-line console script support.
- Exceptions from incorrect dates ranges.
### Fixed 📝
- Issue leading to macOS files not having creation time set.
- `utils.set_from.file_name` exception handling.
- Issue causing microseconds not being retrieved.

## 3.0
### Added ➕
- Editable properties.
### Modified 🔁
- Program files structure.
- Improved documentation.
- Path system.
### Fixed 📝
- Issue leading to Windows directories not having creation time set.

## 2.0
### Added ➕
- `Batch` alias for `Utils.Keep`
- Support for setting dates to directories.
- Support for copying dates to directories.
### Modified 🔁
- Program files structure.
- `File` file path system.
### Fixed 📝
- Bugs.
### Removed 🚫
- `Utils.Swap`
- `fromfn` alias from `Utils.fromname`
- `Utils.fromfile` to `Utils.Name`

## 1.8
### Added ➕
- `Utils.fromfile`

## 1.7
### Fixed 📝
- Bugs.

## 1.6
### Added ➕
- `Utils.Swap`
### Fixed 📝
- Bugs.

## 1.5
### Fixed 📝
- Bugs.

## 1.4
### Added ➕
- `Utils.copy`
### Fixed 📝
- Bugs.

## 1.3
### Modified 🔁
- Renamed:
- `FileDate` to `File`
- `Utils.release` to `Utils.drop`
- Reduced code size.

## 1.2
### Fixed 📝
- Code refraction.
- Bugs.

## 1.1
### Modified 🔁
- Code structure.

## 1.0
- Initial release.
1 change: 1 addition & 0 deletions Documents/Pictures/filedate.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
19 changes: 19 additions & 0 deletions Files/build/lib/filedate/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
"""Simple, convenient and cross-platform file date changing library."""

__author__ = "kubinka0505"
__credits__ = __author__
__version__ = "3.1"
__date__ = "10th February 2024"

#-=-=-=-#

from .config import *
from .core import *
from .utils import *

#-=-=-=-#

if is_win:
del byref, windll

del is_win, is_mac, platform
113 changes: 113 additions & 0 deletions Files/build/lib/filedate/cli_core.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,113 @@
import filedate
from datetime import datetime
from argparse import ArgumentParser, SUPPRESS

Parser = ArgumentParser(
prog = "filedate",
description = "Command-line wrapper for `filedate.core` module.",
epilog = "If no argument is specified, `File.get` function is called, otherwise `File.set`",
add_help = 0,
allow_abbrev = 0
)

#-=-=-=-#
# Groups

Required = Parser.add_argument_group("Required arguments")
Optional = Parser.add_argument_group("Optional arguments")
Switch = Parser.add_argument_group("Switch arguments")

#-=-=-=-#
# Arguments

Required.add_argument(
"-i", "--inputs",
nargs = "*",
type = str,
required = True,
help = "Existing files absolute path."
)

#---#

Optional.add_argument(
"-c", "--created",
default = "",
help = "Date of files creation. Does nothing on non-Windows operating systems."
)
Optional.add_argument(
"-m", "--modified",
default = "",
help = "Date of files modification date."
)
Optional.add_argument(
"-a", "--accessed",
default = "",
help = "Date of files access date."
)

#---#

Switch.add_argument(
"-e", "--expanded",
action = "store_false",
help = "Outputs more precise `datetime.datetime.strftime` format argument pattern."
)

Switch.add_argument(
"-h", "--help",
action = "help",
help = "Shows this message."
)

#-=-=-=-#
# Settings

args = Parser.parse_args()

if args.expanded:
args.format_string = "%d/%m/%Y %H:%M:%S"
else:
args.format_string = "%A, %d{} %B %Y, %H:%M:%S.%f"

#-=-=-=-#
# Functions

def main():
for Input in args.inputs:
input_obj = filedate.File(Input)
_get = input_obj.get()

if not any((args.created, args.modified, args.accessed)):
longest = [k for k in _get.keys()]
longest = sorted(longest, key = len)[-1]
longest = len(longest)

print(input_obj.path)
for key, value in _get.items():
ordinal = "th"

# Ordinals for "--expanded"
if value.day % 10 == 1:
ordinal = "st"

if value.day % 10 == 2:
ordinal = "nd"

if value.day % 10 == 3:
ordinal = "rd"

args.format_string = args.format_string.format(ordinal)

print(
4 * " " + (key.title() + ":").ljust(longest + 1, " "), value.strftime(args.format_string),
)

if Input != args.inputs[-1]:
print()
else:
input_obj.set(
created = args.created if args.created else None,
modified = args.modified if args.modified else None,
accessed = args.accessed if args.accessed else None
)
23 changes: 23 additions & 0 deletions Files/build/lib/filedate/config.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
"""Module configuration classes and variables."""

import os
import subprocess

platform = os.sys.platform.lower()

is_win = platform.startswith("win")
is_mac = platform.startswith("darwin")

#-=-=-=-=-=-#

class exceptions:
SYSTEM = OSError

class date:
WRONG = ValueError("One of the dates could not be converted to a date object")
RANGE_TIMESTAMP_SET = ValueError("Cannot use this `datetime.datetime` object to set the date, as its `timestamp` bound method call fails")
RANGE_DATETIME_SET = ValueError("Cannot set the date not being in the `datetime.datetime` values range")

class path:
NOT_FOUND = FileNotFoundError('File was not found ("{file_path}")')
NO_DATE = ValueError('No date was detected in the parsed path string ("{string}")')
Loading

0 comments on commit d6029fb

Please sign in to comment.