k4j8 / filetailor Goto Github PK
View Code? Open in Web Editor NEWCopy and modify plain text files between devices without templates or symlinks
License: GNU General Public License v3.0
Copy and modify plain text files between devices without templates or symlinks
License: GNU General Public License v3.0
If the YAML specifies a variable to use for a file but it is not defined for a device, it is not converted silently. Instead, a warning should be given to the user.
File permissions are lost through the tailoring process. Use os.open()
to open the files with the same mask as the existing file or the parent folder, which should be available through the already existing stats
variable.
Run this (current code) when stats
is None
:
with open(in_progress_path, 'w') as in_progress_file:
in_progress_file.writelines(source_tailored)
And run this when it isn't:
in_progress_file = os.open(in_progress_path, oct(stats.st_mode))
os.write(in_progress_file, source_tailored)
os.close(in_progress_file)
In addition to include_devices
and exclude_devices
, add options for backup_only_devices
and restore_only_devices
for files. When evaluating if a file should be acted upon, consider devices in the corresponding category as well.
Code to modify below.
In sync.py
,
if ftconfig.sync in [BACKUP]:
includes = ['include_devices', 'backup_only_devices']
elif ftconfig.sync in [STATUS, RESTORE]:
includes = ['include_devices', 'restore_only_devices']
include_devices_all = [cfile.yaml_file[x] for x in includes if include in cfile.yaml_file
# Check if file is for this device
if len(include_devices_all):
if cdevice.device_id not in include_devices_all:
logging.debug('Skipping %s, host not in included list',
cfile.file_id)
return SKIP
elif 'exclude_devices' in cfile.yaml_file:
if cdevice.device_id in cfile.yaml_file['exclude_devices']:
logging.debug('Skipping %s, host in excluded list',
cfile.file_id)
return SKIP
I assume that to use filetailor with git you need to create a git repo of the (by default) ~/.local/share/filetailor
, this is however not clarified.
Alternatively, a closer integration with git (or other tools) could be added, by creating sub-commands which push/pull. I can implementing this, if given the go-ahead.
In sync.py
on the last line of the code below, the code can try to create a directory of the same name as an existing file:
# Create cfile in in-progress_dir
if not cfile.in_progress.is_dir():
if not get_option('dry_run', cfile, cfile.device):
os.mkdir(cfile.in_progress)
Perhaps filetailor should clean the cache when this happens?
I believe the following facts should be made explicit in the documentation. Maybe you have fallen in the typical developer trap and they seem obvious to you, but they aren't and I would have avoided much frustration had I known. This happens to me all the time on programs I myself write, of course. So:
filetailor backup
only comments out the blocks conditional to the current device, and doesn't uncomment anything,filetailor restore
only uncomments the blocks conditional to the current device, and doesn't comment out anything.I hope I got it right.
Thanks for a great idea, btw! A passage between the Scylla of undisciplined proliferating versions of dotfiles and the Charybdis of keeping them in git -- one branch per host -- was badly needed.
Add support for syncing subdirectories. SubFile
needs to be updated to accept the full path.
--test
flag with actual tests, preferably pytest. The tests should include a setup fixture that loads config.py
with test data. Use mock or Monkeypatching to simulate user input.--debug
by using help=argparse.SUPPRESS
for the --debug
option (source).--test
and --debug
are no longer printed when running filetailor --help
, remove the ENVIRONMENT
section from config.ini
and all instances in the code.A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.