wangyuxinwhy / namefile

generate file name from file info https://namefile.readthedocs.io/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

namefile

๐Ÿ’พ Install

you can install namefile with pip:

pip install namefile

๐Ÿ‘‹ Usage

  1. generate file name from file info
from namefile import namefile

name = namefile(
    stem='foo',
    suffix='txt',
    tags=['bar', 'baz'],
    date=datetime.date(2020, 1, 1),
    version=Version('1.0.0'),
)
print(str(name))
# foo-bar-baz.20200101.1.0.0.txt
  1. restore file info from file name
from namefile import nameparse

info = nameparse('foo-bar-baz.20200101.1.0.0.txt')
print(repr(info))
# FileInfo(stem='foo', suffix='txt', tags=['bar', 'baz'], date=datetime.date(2020, 1, 1), version=<Version('1.0.0')>)

About

generate file name from file info https://namefile.readthedocs.io/


Languages

Language:Python 90.5%Language:Makefile 9.5%