NAME§

Util - quilt.Util

FILE§

/Users/timothydavenport/GitHub/quilt/quilt

DESCRIPTION§

Utility functions

Helper functions used all over, but don't belong anywhere.

project : quilt
version : 0.1.1
status : development
modifydate : 2015-05-13 07:09:00 -0700
createdate : 2015-04-28 06:02:00 -0700
website : https://github.com/tmthydvnprt/quilt
author : tmthydvnprt
email : tmthydvnprt@users.noreply.github.com
maintainer : tmthydvnprt
license : MIT
copyright : Copyright 2015, quilt
credits :

MODULES§

bs4, codecs, copy, dt, fnmatch, hashlib, nltk, os, random, string, sys, time, urlparse

FUNCTIONS§

def analyze_post(soup=None, domain='''):

analyze text and structure of post

def check_local_quilt(page='', quilt_pattern=None, default_patches=None, config=None'):

check for directory quilt and directory patches?

def chronological_order(posts=None'):

sort posts in reverse chronological order

def filter_external_url(urls=None, domain='''):

filter file list for external assets

def find_hrefsrc(soup, tag_name='', re_pattern=None'):

search a soup for pattern in href or src of tag

def get_dir_hash(dir_path='''):

Get the check some of each file in directory, and store in dictionary

def get_file_names(source='', extensions='''):

get all file names matching

def get_group(pagevars=None, name='''):

get list of tags or categories

def get_just_words(text='''):

tokenize text, punctuation remove and lowercased

def get_keywords(text='''):

find keywords

def group_links(pagevars=None, name='''):

place tag and category links

def handlebar_replace(template_string='', variables=None'):

replace variables

def load_files(source='', extensions='''):

load all files matching

def make_group_links(groups=None, pagevars=None, name='''):

make link list out of group set or list

def minimize_css(css='''):

minimize css file ported from https://github.com/isaacs/cssmin/blob/master/rules.txt

def minimize_js(js='''):

minimize js file

def parse_css_blocks(css='''):

parse css string into css blocks {}

def path_link_list(path_string='', file_name='''):

create lists of links for each level in a path

def prefix_vendor_css(css='''):

add vendor prefix to css string, if prefixes already exist return original css

def random_placeholder(size=64'):

return a random string of numbers and digits

def read_file(file_path='', encoding='utf-8''):

read a file into a string. assumes utf-8 encoding.

def recursive_glob(source='''):

get all file names matching

def relative_path(filepath='', rootpath='''):

get relative path between a root and file

def reverse_chronological_order(posts=None'):

sort posts in reverse chronological order

def spell_check(text='', correct_words=None'):

spell checking, ignores non-ascii words, and numbers

def summarize_text(text='', sentence_number=4'):

summarizes a text

def time_since(initial_time'):

return the time since the initial time t0

def top_sentences(text='', sentence_number=4, max_chars=250'):

return top sentences or max number of words

def unparse_css_blocks(blocks=None'):

unparse css blocks back into a css string

def vendorfy_at_prefix(blck=None, at_prefix=None'):

handle at prefix rules

def vendorfy_block(blck=None'):

handle block

def vendorfy_block_list(blck=None'):

handle block

def vendorfy_css(block=None'):

adds vendor prefixes to a block of css

def write_file(file_path='', data='''):

write a file from a string. string is utf encoded before

CLASSES§

builtin.object
ProgressBar

class ProgressBar§

description§


implements a comand-line progress bar

descriptors§


update_iteration
increment progress

update_iteration
increment progress

methods§


def animate(self, iterate'):

animate progress

def update_iteration(self, elapsed_iter'):

increment progress

DATA§

AT_RULES

['keyframes']

BG_ZERO_RE

background-position:0;

BLOCK_COMMENT_RE

/\*(?!\!)(.*?)\*/

BODY_STRAINER

body|{}

CHARSETS2_RE

^(\s*@charset [^;]+;\s*)+

CHARSETS_RE

^(.*)(@charset "[^"]*";)

CLEAN_SELECTORS2_RE

\s+([!{};:>+\(\)\],])

CLEAN_SELECTORS_RE

(^|\})([^{]+):([^{]+\{)

DEFAULT_CONFIG

{'copyrighter': 'you', 'buildicon': True, 'atomid': 'randomid', 'keywords': [], 'git': '', 'spellcheck': True, 'patches': 'patches', 'title': 'some default title', 'quiltcomment': True, 'combinecss': True, 'priority': '0.5', 'pageobject': True, 'local': False, 'correctwords': 'correct_words.txt', 'copydate': 2016, 'vendorfycss': True, 'iconsizes': [64, 60, 76, 120, 152], 'assets': 'assets', 'categories': [], 'spellignore': ['maths', 'codehilite'], 'name': 'some name', 'posts': 'posts', 'copymd': True, 'pagecomment': True, 'domain': 'some_name.com', 'page_ext': ['*.html', '*.md'], 'quilt': 'quilt.html', 'patchcomment': True, 'blogsubtitle': 'a blogy blog', 'minimizecss': True, 'images': 'imgs', 'asset_ext': ['*'], 'buildsearch': True, 'author': 'you', 'buildatom': True, 'blogtitle': 'some blog', 'emptywarning': False, 'buildrobot': True, 'iconfile': 'icon.png', 'assetcomment': True, 'email': 'you@some_name.com', 'templates': 'templates', 'patch_ext': ['*.html'], 'buildrss': True, 'description': 'default description', 'tags': [], 'template_ext': ['*.html'], 'combinejs': True, 'rssid': 'randomid', 'changefreq': 'monthly', 'pages': 'pages', 'buildindex': True, 'buildsitemap': True, 'minimizejs': True, 'buildblog': True}

EMPTY_BRACES_RE

[^}]+{}

EXTRA_SPACES_RE

([!{}:;>+\(\[,])\s+

EXT_LINK

((?:[Ff]|[Hh][Tt])[Tt][Pp][Ss]?://[^>]*)

FOUR_ZEROS_RE

:0 0 0 0;

GROUPLINK

<li class="%s"><a href="%s" class="group-link">%s</a></li>

HEAD_STRAINER

head|{}

KEEP_COMMENT_RE

(/\*!.*?\*/)

LEADING_ZERO_DECIMAL_RE

(:|\s)0+\.(\d+)

LINE_COMMENT_RE

^\s*//(?!\!).*$\n

MEDIA_RE

(@media[^{]*[^\s])\(

MISSING_SEMICOLON_RE

([^;\}])}

MORE_THAN_ONE_NEWLINE_RE

\n+

MORE_THAN_ONE_SEMICOLON_RE

;;+

MORE_THAN_ONE_WHITESPACE_RE

\s+

NO_EMPTY_TAGS

['section', 'article', 'header', 'footer', 'h1', 'h2', 'h3', 'h4', 'h5', 'h6', 'hgroup', 'nav', 'aside', 'div', 'main', 'p', 'pre', 'bockquote', 'ol', 'ul', 'li', 'a', 'abbr', 'cite', 'code', 'b', 'strong', 'em', 's', 'q', 'small', 'samp', 'u', 'time', 'var', 'sup', 'sub', 'kdb', 'mark', 'dl', 'dt', 'dd', 'table', 'thead', 'td', 'tr', 'th', 'tbody', 'tfooter']

OPTIONAL_CARRIAGE_RETURN_RE

\r\n?

PLACEHOLDER_SIZE

64

PREFIXES

['transform', 'transition', 'animation', 'perspective', 'perspective-origin', 'padding-start', 'padding-end']

SELECTORCOLON_RE

___SELECTORCOLON___

SEMICOLON_CLOSE_BRACE_RE

;}

SPACED_COLON_RE

 ?: ?

SPACED_EQUAL_RE

 ?= ?

STOPWORDS

set([u'all', u'just', u'being', u'over', u'both', u'through', u'yourselves', u'its', u'before', u'herself', u'had', u'should', u'to', u'only', u'under', u'ours', u'has', u'do', u'them', u'his', u'very', u'they', u'not', u'during', u'now', u'him', u'nor', u'did', u'this', u'she', u'each', u'further', u'where', u'few', u'because', u'doing', u'some', u'are', u'our', u'ourselves', u'out', u'what', u'for', u'while', u'does', u'above', u'between', u't', u'be', u'we', u'who', u'were', u'here', u'hers', u'by', u'on', u'about', u'of', u'against', u's', u'or', u'own', u'into', u'yourself', u'down', u'your', u'from', u'her', u'their', u'there', u'been', u'whom', u'too', u'themselves', u'was', u'until', u'more', u'himself', u'that', u'but', u'don', u'with', u'than', u'those', u'he', u'me', u'myself', u'these', u'up', u'will', u'below', u'can', u'theirs', u'my', u'and', u'then', u'is', u'am', u'it', u'an', u'as', u'itself', u'at', u'have', u'in', u'any', u'if', u'again', u'no', u'when', u'same', u'how', u'other', u'which', u'you', u'after', u'most', u'such', u'why', u'a', u'off', u'i', u'yours', u'so', u'the', u'having', u'once'])

THREE_ZEROS_RE

:0 0 0;

TWO_ZEROS_RE

:0 0;

VENDORS

['-webkit-', '-moz-', '-ms-', '-o-']

WHITESPACE_RE

\s

WORD_RE

^\w+$

ZERO_UNITS_RE

([\s:])(0)(px|em|%|in|cm|mm|pc|pt|ex)
markdown