summaryrefslogtreecommitdiff
path: root/share/python/lib/files.py
diff options
context:
space:
mode:
Diffstat (limited to 'share/python/lib/files.py')
-rw-r--r--share/python/lib/files.py35
1 files changed, 9 insertions, 26 deletions
diff --git a/share/python/lib/files.py b/share/python/lib/files.py
index fa219b4..8c2c3a7 100644
--- a/share/python/lib/files.py
+++ b/share/python/lib/files.py
@@ -1,3 +1,5 @@
+from time import strptime
+
import logging
import os
import re
@@ -5,21 +7,21 @@ import shutil
import time
-def files_create_from_embedded(ctx, filename=None):
- files_make_directory(ctx, path=os.path.dirname(filename) or ".")
+def files_create_from_embedded(ctx, embedded_file=None):
+ files_make_directory(ctx, path=os.path.dirname(embedded_file) or ".")
files_create_from_embedded_with_other_name(
- ctx, filename_on_disk=filename, embedded_filename=filename
+ ctx, filename_on_disk=embedded_file, embedded_file=embedded_file
)
def files_create_from_embedded_with_other_name(
- ctx, filename_on_disk=None, embedded_filename=None
+ ctx, filename_on_disk=None, embedded_file=None
):
get_file = globals()["get_file"]
files_make_directory(ctx, path=os.path.dirname(filename_on_disk) or ".")
with open(filename_on_disk, "wb") as f:
- f.write(get_file(embedded_filename))
+ f.write(get_file(embedded_file))
def files_create_from_text(ctx, filename=None, text=None):
@@ -106,27 +108,8 @@ def files_match(ctx, filename1=None, filename2=None):
assert_eq(data1, data2)
-def files_touch_with_timestamp(
- ctx,
- filename=None,
- year=None,
- month=None,
- day=None,
- hour=None,
- minute=None,
- second=None,
-):
- t = (
- int(year),
- int(month),
- int(day),
- int(hour),
- int(minute),
- int(second),
- -1,
- -1,
- -1,
- )
+def files_touch_with_timestamp(ctx, filename=None, mtime = None):
+ t = strptime(mtime, "%Y-%m-%d %H:%M:%S")
ts = time.mktime(t)
_files_touch(filename, ts)