Giter Site home page Giter Site logo

project-ideas's Introduction

Project Idea: File Watcher

Create a python package that can be configured to watch a single file, multiple files or all files nested within a directory. If a file is modified a user defined callback function is executed.

Example use cases for the package:

  • Run a code formatter every time a file is saved.
  • Backup a newly created file to a storage server
  • Something else?

Implementation:

The following 3 functions should be exposed by the API/package

def watch_single(filename, callback, period):
    """
    :arg filename: name of the file to watch
    :arg callback: function to call when the file is modified
    :arg period: how often the file should be checked e.g. period=1 -> the file is checked every second
    """
    pass
    
def watch_multiple(files, callback, period):
    """
    :arg files: list of filenames to watch
    :arg callback: function to call for each file that is modified
    :arg period: how often the files should be checked e.g. period=1 -> the files are checked every second
    """
    pass
    
def watch_directory(dirname, callback, period):
    """
    :arg dirname: name of the directory to watch
    :args callback: function to call for each file that is modified
    :arg period:  how often the files in the directory should be checked e.g. period=1 -> the files are checked every second
    """
    pass

The callback function will have the following signature:

def some_callback(filename, event_type):
    """Example callback function"""
    
    id event_type == "CREATED":
        # do something
        pass
    elif event_type == "UPDATED":
        # do something
        pass
    elif event_type == "DELETED":
        # do someting
        pass
    else:
        raise Exception("Unknow event type")
            

The event types are:

  • CREATED
  • UPDATED
  • DELETED

Other requirements:

  • Pure python implementation (only use standard library).
  • Should be able to run on MacOS, Windows and linux.
  • Include a simple documentation file on how to use the package
  • Publish the package on PYPI

project-ideas's People

Contributors

ichbinjakes avatar

Watchers

 avatar

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.