GithubHelp home page GithubHelp logo

fptokens's Introduction

fptokens

image

image

image

image

image

image

A library for tokenisable filenames

Full Documentation

Installation

To install fptokens, type:

$ pip install fptokens

Getting Started

To get started with fptokens, type:

import fptokens as fpt

To create a file name, type:

filename = fpt.Filename(root='/Users/demo/Desktop',
                        folders=['assets', '$colors$'],
                        base=['asset', '$colors$', '1200px'])

This created a file name with default settings, _ as the separator, jpg as the extension and $ as the escape character for the tokens.

To parse and convert the tokens of the file name to actual tokens, type:

filename.parse()

To get the results of the parsing, type:

print filename.tokens
# [<Token: $color$>]

The list of tokens could now be used to create permutations of the tokenised file name for example for batch output of image assets.

To create a generator of all permutations, define a set of data for each of the tokens with the token name as the argument name:

for permutation in filename.resolve(colors=['white', 'black', 'red', 'blue']):
    # do something with the permutation
    print permutation.abspath
# /Users/demo/Desktop/assets/white/asset_white_1200px.jpg
# /Users/demo/Desktop/assets/black/asset_black_1200px.jpg
# /Users/demo/Desktop/assets/red/asset_red_1200px.jpg
# /Users/demo/Desktop/assets/blue/asset_blue_1200px.jpg

Once tokens have been replaced with real-world data to create permutations, the relevant folders can be created by typing:

permutation.make()

fptokens's People

Stargazers

 avatar Alex Hughes avatar Ryan J. Quinlan avatar Parimal Desai avatar  avatar

Watchers

James Cloos avatar Florian Einfalt 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.