Giter VIP home page Giter VIP logo

filetailor's People

Contributors

k4j8 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

filetailor's Issues

Add alert for variables not converted

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.

Set file permissions to match when restoring

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)

Allow for restricting to only backup or restore for a 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

Clarification: Integration with git or other tools.

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.

Cache creates error

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?

Document direction of changes

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:

  1. filetailor backup only comments out the blocks conditional to the current device, and doesn't uncomment anything,
  2. 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 testing

  • Replace the --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.
  • Once complete, suppress the help output of --debug by using help=argparse.SUPPRESS for the --debug option (source).
  • Now that --test and --debug are no longer printed when running filetailor --help, remove the ENVIRONMENT section from config.ini and all instances in the code.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.