Python library for downloading css file from the web with it's assets
Python
Switch branches/tags
Nothing to show
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
.gitignore
README
css_extract.py

README

Help on module css_extract:

NAME
    css_extract

FILE
    /home/ki/my_projects/css_extract/css_extract.py

DESCRIPTION
    If you have a css and it contain media that you want to embed to
    your project, you need to download not only this css file, but
    also all the assets that are noted in there.
    
    This package automates this process.
    
    Dependencies:
    
        Wget tool
    
    
    POSIX system is preferable.
    
    USAGE:
    
        To run tests, do:
    
            $ python css_extract.py
    
        Example of API usage:
        (asuming your home folder name is "user")
    
            >>> from css_extract import Extractor
            >>> ex = Extractor('http://python.org/styles/styles.css', '/home/user/python_styles_css')
            >>> ex.asset_urls
            ['../images/header-bg2.png',
             '../images/nav-off-bg.png',
             ...
             'styles.css']
        
            >>> ex.run()
        
        Css file and it's assets will be downloaded preserving tree structure:
        
             python_styles_css /
            ├── images
            │   ├── blank.gif
            │   ├── bullet.gif
            │   ├── button-on-bg.png
            │   ├── header-bg2.png
            │   ├── nav-off-bg.png
            │   └── nav-on-bg.png
            └── styles
                └── styles.css
    
    TODO: option for downloading assets via urllib2

CLASSES
    __builtin__.object
        Extractor
    
    class Extractor(__builtin__.object)
     |  Extractor class implements methods for extraction asset urls from Css file
     |  and downloading them into corresponding folders.
     |  
     |  Methods defined here:
     |  
     |  __init__(self, source_url, dest_path)
     |      Input:
     |                  ``source_url``  Url of the Css on remote sever that contain assets
     |                                  we will be downloading
     |      
     |                  ``dest_path``   DirectoryPath where downloaded css with assets
     |                                  will be stored
     |  
     |  get_asset_list(self)
     |      Get list (generator) of prepared tuples containing assets url,
     |      destination path and asset filename for each asset.
     |  
     |  run(self)
     |      Dowload Css and all it's media assets to the destination directory.
     |  
     |  ----------------------------------------------------------------------
     |  Data descriptors defined here:
     |  
     |  __dict__
     |      dictionary for instance variables (if defined)
     |  
     |  __weakref__
     |      list of weak references to the object (if defined)

FUNCTIONS
    cd(path)
        Change the working directory to `path_to`.
    
    cd_or_create(path, mode=511)
        Same as ``cd()`` but create ``path`` if it doesn't exist.
    
    pwd()
        Get the current working directory.
    
    run_command(command)
        Run a command on local machine and get its output.