├── .DS_Store ├── .codeintel └── config ├── LICENSE-2.0.txt ├── README.md ├── index.wsgi ├── modules ├── .DS_Store └── xcat │ ├── .DS_Store │ ├── __init__.py │ ├── __init__.pyc │ ├── cache.py │ ├── cache.pyc │ ├── form.py │ ├── form.pyc │ ├── models.py │ ├── models.pyc │ ├── plugins.py │ ├── plugins.pyc │ ├── session.py │ ├── session.pyc │ ├── utils.py │ ├── utils.pyc │ ├── web.py │ └── web.pyc ├── requirements.txt ├── static ├── .DS_Store ├── admin │ ├── .DS_Store │ ├── img │ │ └── bg.jpg │ ├── main.coffee │ ├── main.js │ ├── pagination.coffee │ ├── pagination.js │ ├── style.css │ ├── style.less │ ├── tao.coffee │ └── tao.js ├── favicon.ico ├── kind │ ├── .DS_Store │ ├── kindeditor-all-min.js │ ├── plugins │ │ ├── .DS_Store │ │ └── image │ │ │ ├── .DS_Store │ │ │ ├── image.js │ │ │ └── images │ │ │ ├── .DS_Store │ │ │ ├── align_left.gif │ │ │ ├── align_right.gif │ │ │ ├── align_top.gif │ │ │ └── refresh.png │ └── themes │ │ ├── .DS_Store │ │ ├── common │ │ ├── .DS_Store │ │ ├── anchor.gif │ │ ├── blank.gif │ │ ├── flash.gif │ │ ├── loading.gif │ │ ├── media.gif │ │ └── rm.gif │ │ ├── default │ │ ├── .DS_Store │ │ ├── background.png │ │ ├── default.css │ │ └── default.png │ │ └── simple │ │ └── simple.css ├── sea-modules │ ├── .DS_Store │ ├── bootstrap │ │ ├── .DS_Store │ │ ├── 2.1.1 │ │ │ ├── .DS_Store │ │ │ ├── bootstrap.css │ │ │ ├── bootstrap.js │ │ │ └── bootstrap │ │ │ │ ├── modal.coffee │ │ │ │ └── modal.js │ │ └── img │ │ │ ├── .DS_Store │ │ │ ├── glyphicons-halflings-white.png │ │ │ └── glyphicons-halflings.png │ ├── handlebars │ │ └── 1.0.0 │ │ │ └── handlebars.js │ ├── jquery │ │ └── 1.7.2 │ │ │ ├── jquery-debug.js │ │ │ └── jquery.js │ ├── seajs │ │ └── 1.2.1 │ │ │ ├── plugin-base.js │ │ │ ├── plugin-coffee.js │ │ │ ├── plugin-combo.js │ │ │ ├── plugin-debug.js │ │ │ ├── plugin-i18n.js │ │ │ ├── plugin-json.js │ │ │ ├── plugin-less.js │ │ │ ├── plugin-reload.js │ │ │ ├── plugin-storage.js │ │ │ ├── plugin-text.js │ │ │ ├── sea-debug.js │ │ │ └── sea.js │ └── xcat │ │ ├── .DS_Store │ │ └── 1.0.0 │ │ ├── .DS_Store │ │ └── xcat │ │ ├── .DS_Store │ │ ├── form.coffee │ │ ├── form.js │ │ ├── utils.coffee │ │ └── utils.js └── storage │ ├── .DS_Store │ └── file │ ├── .DS_Store │ ├── 07ebdd0c535334dfd5a45904e1763208.png │ ├── 279d5ff501fb7109df0f79d5467f2444.jpeg │ ├── 54bd9433cbe5f4cac90ac9ec6ae9535c.jpeg │ ├── 5704442a7d7001f0796829f1954813b6.jpeg │ ├── 71fbd74565221b196e7166531c29d5ce.jpeg │ ├── 85f0ee7a7ec25210853bd8ff9e4015ab.jpeg │ ├── 97231b3b6e6a89d746d3c0399ec5d09d.jpeg │ ├── a01687117c1fb2885f592e2c0c4ecd22.jpeg │ ├── af02f1681fdacf9af97a2f9a50a48295.jpeg │ ├── b325c14b240d42133deb82eafff00e40.jpeg │ ├── c3dadc65d2c0a1aa2a33248f3808dd43.jpeg │ ├── d0dbf53812d6515a7e236fbccc0394a1.jpeg │ └── f70bba3633421100b25938819a08d924.jpeg └── virtualenv.bundle ├── peewee.py ├── peewee.pyc ├── playhouse ├── __init__.py ├── apsw_ext.py ├── postgres_ext.py ├── signals.py ├── tests_apsw.py ├── tests_postgres.py └── tests_signals.py ├── pwiz.py ├── requests ├── __init__.py ├── __init__.pyc ├── _oauth.py ├── _oauth.pyc ├── api.py ├── api.pyc ├── async.py ├── auth.py ├── auth.pyc ├── cacert.pem ├── certs.py ├── certs.pyc ├── compat.py ├── compat.pyc ├── cookies.py ├── cookies.pyc ├── defaults.py ├── defaults.pyc ├── exceptions.py ├── exceptions.pyc ├── hooks.py ├── hooks.pyc ├── models.py ├── models.pyc ├── packages │ ├── __init__.py │ ├── __init__.pyc │ ├── chardet │ │ ├── __init__.py │ │ ├── __init__.pyc │ │ ├── big5freq.py │ │ ├── big5prober.py │ │ ├── chardistribution.py │ │ ├── charsetgroupprober.py │ │ ├── charsetprober.py │ │ ├── codingstatemachine.py │ │ ├── constants.py │ │ ├── escprober.py │ │ ├── escsm.py │ │ ├── eucjpprober.py │ │ ├── euckrfreq.py │ │ ├── euckrprober.py │ │ ├── euctwfreq.py │ │ ├── euctwprober.py │ │ ├── gb2312freq.py │ │ ├── gb2312prober.py │ │ ├── hebrewprober.py │ │ ├── jisfreq.py │ │ ├── jpcntx.py │ │ ├── langbulgarianmodel.py │ │ ├── langcyrillicmodel.py │ │ ├── langgreekmodel.py │ │ ├── langhebrewmodel.py │ │ ├── langhungarianmodel.py │ │ ├── langthaimodel.py │ │ ├── latin1prober.py │ │ ├── mbcharsetprober.py │ │ ├── mbcsgroupprober.py │ │ ├── mbcssm.py │ │ ├── sbcharsetprober.py │ │ ├── sbcsgroupprober.py │ │ ├── sjisprober.py │ │ ├── universaldetector.py │ │ └── utf8prober.py │ ├── chardet2 │ │ ├── __init__.py │ │ ├── big5freq.py │ │ ├── big5prober.py │ │ ├── chardistribution.py │ │ ├── charsetgroupprober.py │ │ ├── charsetprober.py │ │ ├── codingstatemachine.py │ │ ├── constants.py │ │ ├── escprober.py │ │ ├── escsm.py │ │ ├── eucjpprober.py │ │ ├── euckrfreq.py │ │ ├── euckrprober.py │ │ ├── euctwfreq.py │ │ ├── euctwprober.py │ │ ├── gb2312freq.py │ │ ├── gb2312prober.py │ │ ├── hebrewprober.py │ │ ├── jisfreq.py │ │ ├── jpcntx.py │ │ ├── langbulgarianmodel.py │ │ ├── langcyrillicmodel.py │ │ ├── langgreekmodel.py │ │ ├── langhebrewmodel.py │ │ ├── langhungarianmodel.py │ │ ├── langthaimodel.py │ │ ├── latin1prober.py │ │ ├── mbcharsetprober.py │ │ ├── mbcsgroupprober.py │ │ ├── mbcssm.py │ │ ├── sbcharsetprober.py │ │ ├── sbcsgroupprober.py │ │ ├── sjisprober.py │ │ ├── test.py │ │ ├── universaldetector.py │ │ └── utf8prober.py │ ├── oauthlib │ │ ├── __init__.py │ │ ├── __init__.pyc │ │ ├── common.py │ │ ├── common.pyc │ │ ├── oauth1 │ │ │ ├── __init__.py │ │ │ ├── __init__.pyc │ │ │ └── rfc5849 │ │ │ │ ├── __init__.py │ │ │ │ ├── __init__.pyc │ │ │ │ ├── parameters.py │ │ │ │ ├── parameters.pyc │ │ │ │ ├── signature.py │ │ │ │ ├── signature.pyc │ │ │ │ ├── utils.py │ │ │ │ └── utils.pyc │ │ └── oauth2 │ │ │ ├── __init__.py │ │ │ └── draft25 │ │ │ ├── __init__.py │ │ │ ├── parameters.py │ │ │ ├── tokens.py │ │ │ └── utils.py │ └── urllib3 │ │ ├── __init__.py │ │ ├── __init__.pyc │ │ ├── _collections.py │ │ ├── _collections.pyc │ │ ├── connectionpool.py │ │ ├── connectionpool.pyc │ │ ├── exceptions.py │ │ ├── exceptions.pyc │ │ ├── filepost.py │ │ ├── filepost.pyc │ │ ├── packages │ │ ├── __init__.py │ │ ├── __init__.pyc │ │ ├── ordered_dict.py │ │ ├── ordered_dict.pyc │ │ ├── six.py │ │ ├── six.pyc │ │ └── ssl_match_hostname │ │ │ ├── __init__.py │ │ │ └── __init__.pyc │ │ ├── poolmanager.py │ │ ├── poolmanager.pyc │ │ ├── request.py │ │ ├── request.pyc │ │ ├── response.py │ │ ├── response.pyc │ │ ├── util.py │ │ └── util.pyc ├── safe_mode.py ├── safe_mode.pyc ├── sessions.py ├── sessions.pyc ├── status_codes.py ├── status_codes.pyc ├── structures.py ├── structures.pyc ├── utils.py └── utils.pyc └── requirements.txt /.DS_Store: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vfasky/BlogCatke/6bb4971c5af88f3edd88c6728561728f64316e18/.DS_Store -------------------------------------------------------------------------------- /.codeintel/config: -------------------------------------------------------------------------------- 1 | { 2 | "Python": { 3 | "python": '~/github/local/BlogCatke/ENV/bin/python', 4 | "pythonExtraPaths": [ 5 | '~/github/local/BlogCatke/ENV/lib/python2.7/site-packages', 6 | '~/github/local/BlogCatke/', 7 | '~/github/local/BlogCatke/modules' 8 | ] 9 | } 10 | } -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | Catke Blog 是运行在 SAE 上 2 | ------------------------------------------- 3 | 4 | ### 基于 tornado, html5 小巧,简单,高效的Python Blog。 5 | 6 | 7 | ** 重构中 。。。 ** 8 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /index.wsgi: -------------------------------------------------------------------------------- 1 | #coding=utf-8 2 | 3 | ''' 4 | SAE 的 入口文件 5 | -------------- 6 | 7 | @author vfasky@gmail.com 8 | ''' 9 | 10 | import sys 11 | import os 12 | 13 | # 设置系统编码为utf8 14 | code = sys.getdefaultencoding() 15 | if code != 'utf8': 16 | reload(sys) 17 | sys.setdefaultencoding('utf8') 18 | 19 | 20 | # 加入virtualenv.bundle目录 21 | # @link http://appstack.sinaapp.com/static/doc/release/testing/tools.html#virtualenv 22 | sys.path.insert(0, os.path.join(os.path.dirname(__file__), 'virtualenv.bundle')) 23 | 24 | # 加入第三方类库搜索路径 25 | sys.path.append(os.path.join(os.path.dirname(__file__), 'modules')) 26 | 27 | try: 28 | 29 | # 加载程序配置 30 | from catke import config 31 | from xcat import cache 32 | # 引入Database 33 | from xcat import Database 34 | 35 | # 取缓存实例 36 | cache.client = getattr(cache, config.settings['xcat_cache'][config.settings['run_mode']])() 37 | 38 | 39 | # 加载数据库配置 40 | Database.load_config( 41 | config.settings['database'].get(config.settings['run_mode'],False) 42 | ) 43 | 44 | import xcat.web 45 | import xcat.plugins 46 | from catke import uimodules 47 | 48 | # 加载UImodel 49 | config.settings['ui_modules'] = uimodules 50 | 51 | # run taoke 52 | from catke.handlers import * 53 | application = xcat.web.Application([],**config.settings) 54 | 55 | # 为插件注册 application 56 | xcat.plugins.register_app(application) 57 | # 绑定ACL 58 | xcat.web.Route.acl(application) 59 | 60 | # 绑定路由 61 | xcat.web.Route.routes(application) 62 | 63 | 64 | except Exception, e: 65 | print str(e) 66 | 67 | 68 | 69 | # 本地环境,启动 server 70 | if 'SERVER_SOFTWARE' not in os.environ: 71 | import tornado.ioloop 72 | application.listen(config.settings['port'][config.settings['run_mode']]) 73 | tornado.ioloop.IOLoop.instance().start() -------------------------------------------------------------------------------- /modules/.DS_Store: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vfasky/BlogCatke/6bb4971c5af88f3edd88c6728561728f64316e18/modules/.DS_Store -------------------------------------------------------------------------------- /modules/xcat/.DS_Store: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vfasky/BlogCatke/6bb4971c5af88f3edd88c6728561728f64316e18/modules/xcat/.DS_Store -------------------------------------------------------------------------------- /modules/xcat/__init__.py: -------------------------------------------------------------------------------- 1 | #coding=utf-8 2 | import functools 3 | from xcat import utils 4 | 5 | ''' 6 | ## 访问控制 7 | 8 | 特殊标识: 9 | 10 | - ACL_NO_ROLE 没有角色用户 11 | - ACL_HAS_ROLE 有角色用户 12 | 13 | demo : 14 | acls = [ 15 | {'URI' : 'app.controllers.default.Login' , 'allow' : ('ACL_NO_ROLE')} , 16 | {'URI' : 'app.controllers.admin.*' , 'allow' : ('admin')} , 17 | {'URI' : 'app.controllers.*' , 'deny' : ('black')} , 18 | ] 19 | 20 | ''' 21 | def acl(method): 22 | 23 | # 检查 24 | def check(rule,roles): 25 | 26 | if rule.get('deny',False): 27 | for r in roles : 28 | if r in rule['deny'] : 29 | return False 30 | 31 | if rule.get('allow',False): 32 | for r in roles : 33 | if r in rule['allow'] : 34 | return True 35 | 36 | return False 37 | 38 | 39 | 40 | @functools.wraps(method) 41 | def wrapper(self, transforms, *args, **kwargs): 42 | # 唯一标识 43 | URI = self.__class__.__module__ + '.' + self.__class__.__name__ 44 | # 访问规则 45 | rules = self.settings['acls'] 46 | # 当前用户 47 | current_user = self.current_user 48 | 49 | 50 | # 格式化角色 51 | roles = [] 52 | if None == current_user: 53 | roles.append('ACL_NO_ROLE') 54 | 55 | elif utils.Validators.is_dict(current_user): 56 | if False == current_user.has_key('roles') \ 57 | or 0 == len(current_user['roles']): 58 | 59 | roles.append('ACL_NO_ROLE') 60 | else: 61 | roles.append('ACL_HAS_ROLE') 62 | 63 | for r in current_user['roles']: 64 | roles.append(r) 65 | 66 | for r in rules: 67 | if r['URI'].find('*') == -1 and r['URI'] == URI : 68 | if False == check(r,roles) : 69 | self._transforms = transforms 70 | self.on_access_denied() 71 | return self.finish() 72 | 73 | elif URI.find(r['URI'].split('*')[0]) == 0: 74 | if False == check(r,roles) : 75 | self._transforms = transforms 76 | self.on_access_denied() 77 | return self.finish() 78 | 79 | return method(self, transforms, *args, **kwargs) 80 | 81 | return wrapper 82 | 83 | 84 | class Database(object): 85 | ''' 86 | 数据库 87 | ''' 88 | 89 | # 读标志 90 | READ = 'read' 91 | # 写标志 92 | WRITE = 'write' 93 | 94 | # 配置 95 | _setting = False 96 | 97 | # 连接池 98 | _pool = {} 99 | 100 | @staticmethod 101 | def load_config(settings): 102 | Database._setting = settings 103 | 104 | @staticmethod 105 | def get_adapter(db_type): 106 | adapter = Database._pool.get(db_type, False) 107 | 108 | if adapter : return adapter 109 | 110 | if Database._setting: 111 | adapter = Database._setting['adapter'] + 'Database' 112 | import peewee 113 | if hasattr(peewee,adapter): 114 | for cfg_type in Database._setting['config']: 115 | db_config = Database._setting['config'][cfg_type] 116 | database = db_config.pop('database') 117 | if cfg_type == Database.READ or cfg_type == Database.WRITE: 118 | Database._pool[cfg_type] = getattr(peewee,adapter)(None) 119 | Database._pool[cfg_type].init(database,**db_config) 120 | else: 121 | db_con = getattr(peewee,adapter)(None) 122 | db_con.init(database,**db_config) 123 | Database._pool[Database.READ] = db_con 124 | Database._pool[Database.WRITE] = db_con 125 | break 126 | 127 | 128 | return Database._pool.get(db_type, False) 129 | 130 | @staticmethod 131 | def connect(db_type = 'read'): 132 | adapter = Database.get_adapter(db_type) 133 | 134 | if adapter.is_closed() : 135 | adapter.connect() 136 | return True 137 | return False 138 | 139 | @staticmethod 140 | def close(): 141 | adapter = Database.get_adapter(Database.WRITE) 142 | if adapter and False == adapter.is_closed(): 143 | adapter.close() 144 | adapter = Database.get_adapter(Database.READ) 145 | if adapter and False == adapter.is_closed(): 146 | adapter.close() 147 | 148 | -------------------------------------------------------------------------------- /modules/xcat/__init__.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vfasky/BlogCatke/6bb4971c5af88f3edd88c6728561728f64316e18/modules/xcat/__init__.pyc -------------------------------------------------------------------------------- /modules/xcat/cache.py: -------------------------------------------------------------------------------- 1 | #coding=utf-8 2 | import os 3 | if 'SERVER_SOFTWARE' in os.environ: 4 | import pylibmc 5 | 6 | 7 | class Static(object): 8 | """静态变量缓存""" 9 | 10 | data = {} 11 | 12 | def get(self, key, default=None): 13 | return self.data.get(key, default) 14 | 15 | def set(self, key, value): 16 | self.data[key] = value 17 | 18 | class SaePylibmc(object): 19 | """基于 sae MC 的缓存""" 20 | 21 | mc = False 22 | if 'SERVER_SOFTWARE' in os.environ: 23 | mc = pylibmc.Client() 24 | 25 | def get(self, key, default=None): 26 | ret = self.mc.get(key) 27 | if not ret: 28 | return default 29 | return ret 30 | 31 | def set(self, key, value): 32 | self.mc.set(key, value) 33 | 34 | 35 | client = Static() 36 | 37 | -------------------------------------------------------------------------------- /modules/xcat/cache.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vfasky/BlogCatke/6bb4971c5af88f3edd88c6728561728f64316e18/modules/xcat/cache.pyc -------------------------------------------------------------------------------- /modules/xcat/form.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vfasky/BlogCatke/6bb4971c5af88f3edd88c6728561728f64316e18/modules/xcat/form.pyc -------------------------------------------------------------------------------- /modules/xcat/models.py: -------------------------------------------------------------------------------- 1 | #coding=utf-8 2 | from peewee import * 3 | from xcat import Database 4 | 5 | Model._meta.database = Database.get_adapter(Database.READ) 6 | 7 | class Model(Model): 8 | """ 9 | 基础模型 10 | """ 11 | class Meta: 12 | database = Database.get_adapter(Database.READ) 13 | 14 | @classmethod 15 | def raw(cls, sql, *params): 16 | cls._meta.database = Database.get_adapter(Database.READ) 17 | return super(Model,cls).raw(sql, *params) 18 | 19 | @classmethod 20 | def select(cls, *selection): 21 | cls._meta.database = Database.get_adapter(Database.READ) 22 | return super(Model,cls).select(*selection) 23 | 24 | @classmethod 25 | def update(cls, **update): 26 | cls._meta.database = Database.get_adapter(Database.WRITE) 27 | return super(Model,cls).update(**update) 28 | 29 | @classmethod 30 | def insert(cls, **insert): 31 | cls._meta.database = Database.get_adapter(Database.WRITE) 32 | return super(Model,cls).insert(**insert) 33 | 34 | @classmethod 35 | def delete(cls): 36 | cls._meta.database = Database.get_adapter(Database.WRITE) 37 | return super(Model,cls).delete() 38 | 39 | @classmethod 40 | def create(cls, **query): 41 | cls._meta.database = Database.get_adapter(Database.WRITE) 42 | return super(Model,cls).create(**query) 43 | 44 | @classmethod 45 | def create_table(cls, fail_silently=False): 46 | cls._meta.database = Database.get_adapter(Database.WRITE) 47 | return super(Model,cls).create_table(fail_silently) 48 | 49 | @classmethod 50 | def drop_table(cls, fail_silently=False): 51 | cls._meta.database = Database.get_adapter(Database.WRITE) 52 | return super(Model,cls).drop_table(fail_silently) 53 | 54 | def save(self, force_insert=False): 55 | self._meta.database = Database.get_adapter(Database.WRITE) 56 | return super(Model,self).save(force_insert) 57 | 58 | class Session(Model): 59 | ''' 60 | session 61 | ''' 62 | id = CharField(max_length=64,primary_key=True) 63 | user_id = IntegerField() 64 | time_out = IntegerField() 65 | left_time = IntegerField() 66 | values = TextField() 67 | 68 | class Plugins(Model): 69 | """ 70 | 插件 71 | """ 72 | name = CharField(max_length=100,unique=True) 73 | bind = TextField() 74 | handlers = TextField(default='[]') # 控制器 75 | ui_modules = TextField(default='[]') # ui_modules 76 | config = TextField(default='{}') # 配置 77 | 78 | -------------------------------------------------------------------------------- /modules/xcat/models.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vfasky/BlogCatke/6bb4971c5af88f3edd88c6728561728f64316e18/modules/xcat/models.pyc -------------------------------------------------------------------------------- /modules/xcat/plugins.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vfasky/BlogCatke/6bb4971c5af88f3edd88c6728561728f64316e18/modules/xcat/plugins.pyc -------------------------------------------------------------------------------- /modules/xcat/session.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vfasky/BlogCatke/6bb4971c5af88f3edd88c6728561728f64316e18/modules/xcat/session.pyc -------------------------------------------------------------------------------- /modules/xcat/utils.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vfasky/BlogCatke/6bb4971c5af88f3edd88c6728561728f64316e18/modules/xcat/utils.pyc -------------------------------------------------------------------------------- /modules/xcat/web.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vfasky/BlogCatke/6bb4971c5af88f3edd88c6728561728f64316e18/modules/xcat/web.pyc -------------------------------------------------------------------------------- /requirements.txt: -------------------------------------------------------------------------------- 1 | tornado==2.1.1 2 | PIL 3 | requests 4 | peewee -------------------------------------------------------------------------------- /static/.DS_Store: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vfasky/BlogCatke/6bb4971c5af88f3edd88c6728561728f64316e18/static/.DS_Store -------------------------------------------------------------------------------- /static/admin/.DS_Store: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vfasky/BlogCatke/6bb4971c5af88f3edd88c6728561728f64316e18/static/admin/.DS_Store -------------------------------------------------------------------------------- /static/admin/img/bg.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vfasky/BlogCatke/6bb4971c5af88f3edd88c6728561728f64316e18/static/admin/img/bg.jpg -------------------------------------------------------------------------------- /static/admin/main.coffee: -------------------------------------------------------------------------------- 1 | define (require, exports, module) -> 2 | 3 | # 加载 bootstrap 4 | jQuery = require 'bootstrap' 5 | 6 | -------------------------------------------------------------------------------- /static/admin/main.js: -------------------------------------------------------------------------------- 1 | // Generated by CoffeeScript 1.3.3 2 | (function() { 3 | 4 | define(function(require, exports, module) { 5 | var jQuery; 6 | return jQuery = require('bootstrap'); 7 | }); 8 | 9 | }).call(this); 10 | -------------------------------------------------------------------------------- /static/admin/pagination.coffee: -------------------------------------------------------------------------------- 1 | define (require, exports, module) -> 2 | 3 | # 加载 bootstrap 4 | jQuery = require 'bootstrap' 5 | 6 | class Pagination 7 | 8 | constructor: (@count,@current_page=1,@page_size=10,@max=10) -> 9 | @count = Number(@count) 10 | @current_page = Number(@current_page) 11 | @count_page = Math.ceil( @count / @page_size ) 12 | 13 | if @current_page > @count_page 14 | @current_page = @count_page 15 | 16 | @next_page = @current_page + 1 17 | if @next_page >= @count_page 18 | @next_page = @count_page 19 | 20 | @prev_page = @current_page - 1 21 | if @prev_page < 1 22 | @prev_page = 1 23 | 24 | build_left: -> 25 | if @count_page < @max 26 | return [1...(@count_page + 1)] 27 | 28 | c_max = Math.ceil( @max / 2 ) 29 | 30 | if @current_page <= c_max 31 | return [1...c_max] 32 | 33 | return [(@current_page - c_max)...@current_page] 34 | 35 | build_right: -> 36 | return [] if @count_page < @max 37 | 38 | c_max = Math.ceil( @max / 2 ) 39 | if @current_page <= c_max 40 | return [c_max...(@max + 1)] 41 | if (@current_page + c_max) > @count_page 42 | return [@current_page...(@count_page + 1) ] 43 | 44 | return [@current_page...(@current_page + c_max) ] 45 | 46 | 47 | render: (callback)-> 48 | return jQuery('') if @count_page < 2 49 | 50 | list = @build_left() 51 | for v in @build_right() 52 | list.push v 53 | 54 | list_html = [] 55 | for v in list 56 | if v != @current_page 57 | list_html.push "
  • #{v}
  • " 58 | else 59 | list_html.push "
  • #{v}
  • " 60 | 61 | dom = jQuery " 62 | 69 | " 70 | 71 | dom.find('li.page').click -> 72 | callback Number(jQuery(@).attr('page')) 73 | return false 74 | 75 | dom.find('li.prev').click => 76 | callback @prev_page 77 | return false 78 | 79 | dom.find('li.next').click => 80 | callback @next_page 81 | return false 82 | 83 | dom 84 | 85 | 86 | Pagination -------------------------------------------------------------------------------- /static/admin/style.css: -------------------------------------------------------------------------------- 1 | header { 2 | background: #205081; 3 | border-bottom: 3px solid #2E3D54; 4 | color: #FFFFFF; 5 | padding: 0 10px; 6 | height: 40px; 7 | line-height: 40px; 8 | } 9 | header h1 { 10 | margin: 0; 11 | font-size: 20px; 12 | padding-left: 20px; 13 | } 14 | footer { 15 | clear: both; 16 | height: 99px; 17 | margin-top: 40px; 18 | background: #F5F5F5; 19 | border-top: 1px solid #DDDDDD; 20 | } 21 | footer .info { 22 | padding: 20px; 23 | } 24 | .form-wrap { 25 | border: 1px solid #ddd; 26 | border-radius: 6px 6px 0 0 ; 27 | } 28 | .form-wrap form { 29 | margin-bottom: 0; 30 | padding-top: 20px; 31 | } 32 | .form-wrap form .control-group { 33 | padding-left: 20px; 34 | } 35 | .form-wrap .form-actions { 36 | margin-bottom: 0; 37 | } 38 | .admin-main { 39 | padding-top: 25px; 40 | background: url(img/bg.jpg) repeat-x; 41 | } 42 | #select-goods { 43 | position: relative; 44 | } 45 | #select-goods .thumbnails { 46 | padding-top: 20px; 47 | display: none; 48 | clear: both; 49 | } 50 | #select-goods .commission-box { 51 | display: none; 52 | position: absolute; 53 | top: 40px; 54 | } 55 | #select-goods .search-form, 56 | #select-goods .btn-group, 57 | #select-goods button { 58 | display: inline; 59 | margin-right: 4px; 60 | } 61 | #select-goods .items-btn, 62 | #select-goods .commission-btn { 63 | float: left; 64 | } 65 | .item-info .comments { 66 | float: right; 67 | width: 200px; 68 | } 69 | .item-info .comments .comment-box { 70 | padding: 8px 0; 71 | border-bottom: 1px solid #ddd; 72 | } 73 | .item-info .comments .user { 74 | color: #999; 75 | margin-bottom: 2px; 76 | } 77 | .item-info .comments .comment { 78 | padding-left: 6px; 79 | font-size: 13px; 80 | } 81 | .item-info .comments img { 82 | float: left; 83 | width: 20px; 84 | border-radius: 10px; 85 | box-shadow: 0 0 2px #333; 86 | margin-right: 5px; 87 | } 88 | .item-info .avatar { 89 | max-width: 50px; 90 | max-height: 50px; 91 | float: left; 92 | box-shadow: 0 0 3px #222; 93 | margin: 0px 12px 5px 0px; 94 | border-radius: 25px; 95 | } 96 | .item-info .html { 97 | width: 740px; 98 | overflow: hidden; 99 | } 100 | .item-info .html img { 101 | max-width: 720px; 102 | } 103 | .pagination-wrap { 104 | clear: both; 105 | padding: 6px; 106 | } 107 | #goods-list { 108 | padding-top: 12px; 109 | } 110 | #goods-list .box { 111 | float: left; 112 | padding: 6px; 113 | border: 1px solid #ddd; 114 | margin: 12px; 115 | width: 200px; 116 | height: 300px; 117 | overflow: hidden; 118 | position: relative; 119 | box-shadow: 0 0 6px #999; 120 | } 121 | #goods-list .box .load { 122 | position: absolute; 123 | top: 0; 124 | left: 0; 125 | width: 100%; 126 | height: 100%; 127 | line-height: 300px; 128 | z-index: 10; 129 | background: rgba(0, 0, 0, 0.5); 130 | text-align: center; 131 | color: #fff; 132 | font-size: 20px; 133 | } 134 | #goods-list .box img { 135 | position: relative; 136 | z-index: 1; 137 | max-width: 200px; 138 | max-height: 200px; 139 | cursor: pointer; 140 | } 141 | #goods-list .box strong { 142 | display: block; 143 | height: 40px; 144 | overflow: hidden; 145 | } 146 | #goods-list .box hr { 147 | margin: 5px; 148 | } 149 | #goods-list .box .badge { 150 | float: right; 151 | margin-top: 4px; 152 | } 153 | #goods-list .box .price { 154 | float: left; 155 | position: relative; 156 | z-index: 2; 157 | margin-top: -48px; 158 | font-weight: bold; 159 | font-size: 25px; 160 | color: #ff6600; 161 | width: 200px; 162 | text-shadow: 1px 0 0 #333; 163 | box-shadow: 0 0 3px #333; 164 | background: rgba(0, 0, 0, 0.5); 165 | display: block; 166 | padding: 6px 0; 167 | text-align: center; 168 | } 169 | -------------------------------------------------------------------------------- /static/admin/style.less: -------------------------------------------------------------------------------- 1 | @Bcolor : #205081; 2 | 3 | header{ 4 | background: @Bcolor; 5 | border-bottom: 3px solid #2E3D54; 6 | color: #FFFFFF; 7 | padding: 0 10px; 8 | height: 40px; 9 | line-height: 40px; 10 | 11 | h1{ 12 | margin:0; 13 | font-size:20px; 14 | padding-left: 20px; 15 | } 16 | } 17 | 18 | footer{ 19 | clear: both; 20 | height: 99px; 21 | margin-top: 40px; 22 | background: #F5F5F5; 23 | border-top: 1px solid #DDDDDD; 24 | 25 | .info{ 26 | padding: 20px; 27 | } 28 | } 29 | .form-wrap{ 30 | border: 1px solid #ddd; 31 | border-radius: 6px 6px 0 0 ; 32 | form{ 33 | margin-bottom: 0; 34 | padding-top: 20px; 35 | .control-group{ 36 | padding-left: 20px; 37 | } 38 | 39 | } 40 | 41 | .form-actions{ 42 | margin-bottom: 0; 43 | } 44 | } 45 | .admin-main{ 46 | padding-top:25px; 47 | background: url(img/bg.jpg) repeat-x; 48 | } 49 | 50 | #select-goods{ 51 | position: relative; 52 | 53 | .thumbnails { 54 | padding-top: 20px; 55 | display: none; 56 | clear: both; 57 | } 58 | 59 | .commission-box{ 60 | display: none; 61 | position: absolute; 62 | top: 40px; 63 | } 64 | 65 | .search-form, .btn-group , button{ 66 | display: inline; 67 | margin-right: 4px; 68 | 69 | } 70 | 71 | .items-btn , .commission-btn{ 72 | float: left; 73 | } 74 | } 75 | 76 | .item-info{ 77 | 78 | .comments{ 79 | float: right; 80 | width: 200px; 81 | 82 | .comment-box{ 83 | padding: 8px 0; 84 | border-bottom: 1px solid #ddd; 85 | } 86 | 87 | .user{ 88 | color: #999; 89 | margin-bottom: 2px; 90 | } 91 | 92 | .comment{ 93 | padding-left: 6px; 94 | font-size: 13px; 95 | } 96 | 97 | img{ 98 | float: left; 99 | width : 20px; 100 | border-radius: 10px; 101 | box-shadow: 0 0 2px #333; 102 | margin-right: 5px; 103 | } 104 | } 105 | 106 | .avatar{ 107 | max-width: 50px; 108 | max-height: 50px; 109 | float: left; 110 | box-shadow: 0 0 3px #222; 111 | margin: 0px 12px 5px 0px; 112 | border-radius: 25px; 113 | } 114 | 115 | .html{ 116 | width: 740px; 117 | overflow: hidden; 118 | 119 | img{ 120 | max-width: 720px; 121 | } 122 | } 123 | } 124 | 125 | .pagination-wrap{ 126 | clear: both; 127 | 128 | padding: 6px; 129 | } 130 | 131 | #goods-list{ 132 | padding-top: 12px; 133 | .box{ 134 | 135 | float: left; 136 | padding: 6px; 137 | border: 1px solid #ddd; 138 | margin: 12px; 139 | width: 200px; 140 | height: 300px; 141 | overflow: hidden; 142 | position: relative; 143 | box-shadow: 0 0 6px #999; 144 | 145 | .load{ 146 | position: absolute; 147 | top: 0; 148 | left: 0; 149 | width: 100%; 150 | height: 100%; 151 | line-height: 300px; 152 | z-index: 10; 153 | background: rgba(0,0,0,.5); 154 | text-align: center; 155 | color: #fff; 156 | font-size: 20px; 157 | } 158 | 159 | img{ 160 | position: relative; 161 | z-index: 1; 162 | max-width: 200px; 163 | max-height: 200px; 164 | cursor: pointer; 165 | } 166 | 167 | strong{ 168 | display: block; 169 | height: 40px; 170 | overflow: hidden; 171 | } 172 | 173 | hr{ 174 | margin: 5px; 175 | } 176 | .badge{ 177 | float: right; 178 | margin-top: 4px; 179 | } 180 | 181 | .price{ 182 | float: left; 183 | position: relative; 184 | z-index: 2; 185 | margin-top: -48px; 186 | font-weight: bold; 187 | font-size: 25px; 188 | color: #ff6600; 189 | width: 200px; 190 | text-shadow: 1px 0 0 #333; 191 | box-shadow: 0 0 3px #333; 192 | background: rgba(0,0,0,.5); 193 | display: block; 194 | padding: 6px 0; 195 | text-align: center; 196 | } 197 | } 198 | } -------------------------------------------------------------------------------- /static/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vfasky/BlogCatke/6bb4971c5af88f3edd88c6728561728f64316e18/static/favicon.ico -------------------------------------------------------------------------------- /static/kind/.DS_Store: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vfasky/BlogCatke/6bb4971c5af88f3edd88c6728561728f64316e18/static/kind/.DS_Store -------------------------------------------------------------------------------- /static/kind/plugins/.DS_Store: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vfasky/BlogCatke/6bb4971c5af88f3edd88c6728561728f64316e18/static/kind/plugins/.DS_Store -------------------------------------------------------------------------------- /static/kind/plugins/image/.DS_Store: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vfasky/BlogCatke/6bb4971c5af88f3edd88c6728561728f64316e18/static/kind/plugins/image/.DS_Store -------------------------------------------------------------------------------- /static/kind/plugins/image/images/.DS_Store: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vfasky/BlogCatke/6bb4971c5af88f3edd88c6728561728f64316e18/static/kind/plugins/image/images/.DS_Store -------------------------------------------------------------------------------- /static/kind/plugins/image/images/align_left.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vfasky/BlogCatke/6bb4971c5af88f3edd88c6728561728f64316e18/static/kind/plugins/image/images/align_left.gif -------------------------------------------------------------------------------- /static/kind/plugins/image/images/align_right.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vfasky/BlogCatke/6bb4971c5af88f3edd88c6728561728f64316e18/static/kind/plugins/image/images/align_right.gif -------------------------------------------------------------------------------- /static/kind/plugins/image/images/align_top.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vfasky/BlogCatke/6bb4971c5af88f3edd88c6728561728f64316e18/static/kind/plugins/image/images/align_top.gif -------------------------------------------------------------------------------- /static/kind/plugins/image/images/refresh.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vfasky/BlogCatke/6bb4971c5af88f3edd88c6728561728f64316e18/static/kind/plugins/image/images/refresh.png -------------------------------------------------------------------------------- /static/kind/themes/.DS_Store: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vfasky/BlogCatke/6bb4971c5af88f3edd88c6728561728f64316e18/static/kind/themes/.DS_Store -------------------------------------------------------------------------------- /static/kind/themes/common/.DS_Store: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vfasky/BlogCatke/6bb4971c5af88f3edd88c6728561728f64316e18/static/kind/themes/common/.DS_Store -------------------------------------------------------------------------------- /static/kind/themes/common/anchor.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vfasky/BlogCatke/6bb4971c5af88f3edd88c6728561728f64316e18/static/kind/themes/common/anchor.gif -------------------------------------------------------------------------------- /static/kind/themes/common/blank.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vfasky/BlogCatke/6bb4971c5af88f3edd88c6728561728f64316e18/static/kind/themes/common/blank.gif -------------------------------------------------------------------------------- /static/kind/themes/common/flash.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vfasky/BlogCatke/6bb4971c5af88f3edd88c6728561728f64316e18/static/kind/themes/common/flash.gif -------------------------------------------------------------------------------- /static/kind/themes/common/loading.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vfasky/BlogCatke/6bb4971c5af88f3edd88c6728561728f64316e18/static/kind/themes/common/loading.gif -------------------------------------------------------------------------------- /static/kind/themes/common/media.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vfasky/BlogCatke/6bb4971c5af88f3edd88c6728561728f64316e18/static/kind/themes/common/media.gif -------------------------------------------------------------------------------- /static/kind/themes/common/rm.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vfasky/BlogCatke/6bb4971c5af88f3edd88c6728561728f64316e18/static/kind/themes/common/rm.gif -------------------------------------------------------------------------------- /static/kind/themes/default/.DS_Store: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vfasky/BlogCatke/6bb4971c5af88f3edd88c6728561728f64316e18/static/kind/themes/default/.DS_Store -------------------------------------------------------------------------------- /static/kind/themes/default/background.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vfasky/BlogCatke/6bb4971c5af88f3edd88c6728561728f64316e18/static/kind/themes/default/background.png -------------------------------------------------------------------------------- /static/kind/themes/default/default.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vfasky/BlogCatke/6bb4971c5af88f3edd88c6728561728f64316e18/static/kind/themes/default/default.png -------------------------------------------------------------------------------- /static/kind/themes/simple/simple.css: -------------------------------------------------------------------------------- 1 | /* container */ 2 | .ke-container-simple { 3 | display: block; 4 | border: 1px solid #CCC; 5 | background-color: #FFF; 6 | overflow: hidden; 7 | } 8 | /* toolbar */ 9 | .ke-container-simple .ke-toolbar { 10 | border-bottom: 1px solid #CCC; 11 | background-color: #FFF; 12 | padding: 2px 5px; 13 | overflow: hidden; 14 | } 15 | .ke-container-simple .ke-toolbar .ke-outline { 16 | border: 1px solid #FFF; 17 | background-color: transparent; 18 | margin: 1px; 19 | padding: 1px 2px; 20 | font-size: 0; 21 | line-height: 0; 22 | overflow: hidden; 23 | cursor: pointer; 24 | } 25 | .ke-container-simple .ke-toolbar .ke-on { 26 | border: 1px solid #5690D2; 27 | } 28 | .ke-container-simple .ke-toolbar .ke-selected { 29 | border: 1px solid #5690D2; 30 | background-color: #E9EFF6; 31 | } 32 | .ke-container-simple .ke-toolbar .ke-disabled { 33 | cursor: default; 34 | } 35 | /* statusbar */ 36 | .ke-container-simple .ke-statusbar { 37 | position: relative; 38 | background-color: #FFF; 39 | border-top: 1px solid #CCCCCC; 40 | font-size: 0; 41 | line-height: 0; 42 | *height: 12px; 43 | overflow: hidden; 44 | text-align: center; 45 | cursor: s-resize; 46 | } 47 | /* menu */ 48 | .ke-menu-simple { 49 | border: 1px solid #A0A0A0; 50 | background-color: #FFF; 51 | color: #222222; 52 | padding: 2px; 53 | font-family: "sans serif",tahoma,verdana,helvetica; 54 | font-size: 12px; 55 | text-align: left; 56 | overflow: hidden; 57 | } 58 | .ke-menu-simple .ke-menu-item { 59 | border: 1px solid #FFF; 60 | background-color: #FFF; 61 | color: #222222; 62 | height: 24px; 63 | overflow: hidden; 64 | cursor: pointer; 65 | } 66 | .ke-menu-simple .ke-menu-item-on { 67 | border: 1px solid #5690D2; 68 | background-color: #FFF; 69 | } 70 | /* colorpicker */ 71 | .ke-colorpicker-simple { 72 | border: 1px solid #A0A0A0; 73 | background-color: #FEFEFE; 74 | color: #222222; 75 | padding: 2px; 76 | } 77 | .ke-colorpicker-simple .ke-colorpicker-cell { 78 | font-size: 0; 79 | line-height: 0; 80 | border: 1px solid #FEFEFE; 81 | cursor: pointer; 82 | margin:3px; 83 | padding:0; 84 | } 85 | .ke-colorpicker-simple .ke-colorpicker-cell-top { 86 | font-family: "sans serif",tahoma,verdana,helvetica; 87 | font-size: 12px; 88 | line-height: 24px; 89 | border: 1px solid #FEFEFE; 90 | cursor: pointer; 91 | margin:0; 92 | padding:0; 93 | text-align: center; 94 | } 95 | .ke-colorpicker-simple .ke-colorpicker-cell-on { 96 | border: 1px solid #5690D2; 97 | } 98 | .ke-colorpicker-simple .ke-colorpicker-cell-selected { 99 | border: 1px solid #2446AB; 100 | } 101 | -------------------------------------------------------------------------------- /static/sea-modules/.DS_Store: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vfasky/BlogCatke/6bb4971c5af88f3edd88c6728561728f64316e18/static/sea-modules/.DS_Store -------------------------------------------------------------------------------- /static/sea-modules/bootstrap/.DS_Store: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vfasky/BlogCatke/6bb4971c5af88f3edd88c6728561728f64316e18/static/sea-modules/bootstrap/.DS_Store -------------------------------------------------------------------------------- /static/sea-modules/bootstrap/2.1.1/.DS_Store: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vfasky/BlogCatke/6bb4971c5af88f3edd88c6728561728f64316e18/static/sea-modules/bootstrap/2.1.1/.DS_Store -------------------------------------------------------------------------------- /static/sea-modules/bootstrap/2.1.1/bootstrap/modal.coffee: -------------------------------------------------------------------------------- 1 | define (require, exports) -> 2 | jQuery = require '../bootstrap' 3 | 4 | class Base 5 | constructor: (args = header : '' , body : '' , footer : '') -> 6 | 7 | @dom = jQuery " 8 | 20 | " 21 | @dom.find('.close').click => 22 | @hide() 23 | 24 | @dom.modal( 25 | show : false 26 | ) 27 | 28 | @init() 29 | 30 | init: -> 31 | false 32 | 33 | show: -> 34 | @dom.modal('show') 35 | 36 | hide: -> 37 | @dom.modal('hide') 38 | 39 | remove: -> 40 | @dom.modal('hide') 41 | @dom.remove() 42 | 43 | class Alert extends Base 44 | constructor: (args = {}) -> 45 | title = args.title ? '提示信息!' 46 | content = args.content ? '' 47 | buttons = " 48 | 确认 49 | " 50 | 51 | @callback = args.callback ? -> 52 | 53 | super( 54 | header : title , 55 | body : content , 56 | footer : buttons 57 | ) 58 | 59 | init: -> 60 | 61 | @dom.find('.confirm-yes').click => 62 | @remove() 63 | @callback(true) 64 | false 65 | 66 | @show() 67 | 68 | hide: -> 69 | @callback(false) 70 | @remove() 71 | 72 | 73 | 74 | 75 | class Confirm extends Base 76 | 77 | constructor: (args = {}) -> 78 | title = args.title ? '提示信息!' 79 | content = args.content ? '您确认执行此操作?' 80 | buttons = " 81 | 取消 82 | 确认 83 | " 84 | 85 | @callback = args.callback ? -> 86 | 87 | super( 88 | header : title , 89 | body : content , 90 | footer : buttons 91 | ) 92 | 93 | init: -> 94 | @dom.find('.confirm-no').click => 95 | @remove() 96 | @callback(false) 97 | false 98 | 99 | @dom.find('.confirm-yes').click => 100 | @remove() 101 | @callback(true) 102 | false 103 | 104 | hide: -> 105 | @callback(false) 106 | @remove() 107 | 108 | 109 | 110 | 111 | exports.Base = Base 112 | exports.Confirm = Confirm 113 | exports.Alert = Alert 114 | return 115 | -------------------------------------------------------------------------------- /static/sea-modules/bootstrap/2.1.1/bootstrap/modal.js: -------------------------------------------------------------------------------- 1 | // Generated by CoffeeScript 1.3.3 2 | (function() { 3 | var __hasProp = {}.hasOwnProperty, 4 | __extends = function(child, parent) { for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; }; 5 | 6 | define(function(require, exports) { 7 | var Alert, Base, Confirm, jQuery; 8 | jQuery = require('../bootstrap'); 9 | Base = (function() { 10 | 11 | function Base(args) { 12 | var _this = this; 13 | if (args == null) { 14 | args = { 15 | header: '', 16 | body: '', 17 | footer: '' 18 | }; 19 | } 20 | this.dom = jQuery(""); 21 | this.dom.find('.close').click(function() { 22 | return _this.hide(); 23 | }); 24 | this.dom.modal({ 25 | show: false 26 | }); 27 | this.init(); 28 | } 29 | 30 | Base.prototype.init = function() { 31 | return false; 32 | }; 33 | 34 | Base.prototype.show = function() { 35 | return this.dom.modal('show'); 36 | }; 37 | 38 | Base.prototype.hide = function() { 39 | return this.dom.modal('hide'); 40 | }; 41 | 42 | Base.prototype.remove = function() { 43 | this.dom.modal('hide'); 44 | return this.dom.remove(); 45 | }; 46 | 47 | return Base; 48 | 49 | })(); 50 | Alert = (function(_super) { 51 | 52 | __extends(Alert, _super); 53 | 54 | function Alert(args) { 55 | var buttons, content, title, _ref, _ref1, _ref2; 56 | if (args == null) { 57 | args = {}; 58 | } 59 | title = (_ref = args.title) != null ? _ref : '提示信息!'; 60 | content = (_ref1 = args.content) != null ? _ref1 : ''; 61 | buttons = " 确认 "; 62 | this.callback = (_ref2 = args.callback) != null ? _ref2 : function() {}; 63 | Alert.__super__.constructor.call(this, { 64 | header: title, 65 | body: content, 66 | footer: buttons 67 | }); 68 | } 69 | 70 | Alert.prototype.init = function() { 71 | var _this = this; 72 | this.dom.find('.confirm-yes').click(function() { 73 | _this.remove(); 74 | _this.callback(true); 75 | return false; 76 | }); 77 | return this.show(); 78 | }; 79 | 80 | Alert.prototype.hide = function() { 81 | this.callback(false); 82 | return this.remove(); 83 | }; 84 | 85 | return Alert; 86 | 87 | })(Base); 88 | Confirm = (function(_super) { 89 | 90 | __extends(Confirm, _super); 91 | 92 | function Confirm(args) { 93 | var buttons, content, title, _ref, _ref1, _ref2; 94 | if (args == null) { 95 | args = {}; 96 | } 97 | title = (_ref = args.title) != null ? _ref : '提示信息!'; 98 | content = (_ref1 = args.content) != null ? _ref1 : '您确认执行此操作?'; 99 | buttons = " 取消 确认 "; 100 | this.callback = (_ref2 = args.callback) != null ? _ref2 : function() {}; 101 | Confirm.__super__.constructor.call(this, { 102 | header: title, 103 | body: content, 104 | footer: buttons 105 | }); 106 | } 107 | 108 | Confirm.prototype.init = function() { 109 | var _this = this; 110 | this.dom.find('.confirm-no').click(function() { 111 | _this.remove(); 112 | _this.callback(false); 113 | return false; 114 | }); 115 | return this.dom.find('.confirm-yes').click(function() { 116 | _this.remove(); 117 | _this.callback(true); 118 | return false; 119 | }); 120 | }; 121 | 122 | Confirm.prototype.hide = function() { 123 | this.callback(false); 124 | return this.remove(); 125 | }; 126 | 127 | return Confirm; 128 | 129 | })(Base); 130 | exports.Base = Base; 131 | exports.Confirm = Confirm; 132 | exports.Alert = Alert; 133 | }); 134 | 135 | }).call(this); 136 | -------------------------------------------------------------------------------- /static/sea-modules/bootstrap/img/.DS_Store: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vfasky/BlogCatke/6bb4971c5af88f3edd88c6728561728f64316e18/static/sea-modules/bootstrap/img/.DS_Store -------------------------------------------------------------------------------- /static/sea-modules/bootstrap/img/glyphicons-halflings-white.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vfasky/BlogCatke/6bb4971c5af88f3edd88c6728561728f64316e18/static/sea-modules/bootstrap/img/glyphicons-halflings-white.png -------------------------------------------------------------------------------- /static/sea-modules/bootstrap/img/glyphicons-halflings.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vfasky/BlogCatke/6bb4971c5af88f3edd88c6728561728f64316e18/static/sea-modules/bootstrap/img/glyphicons-halflings.png -------------------------------------------------------------------------------- /static/sea-modules/seajs/1.2.1/plugin-base.js: -------------------------------------------------------------------------------- 1 | define("seajs/plugin-base",[],function(m,k){var l=seajs.pluginSDK,i=l.util,h=l.Module,g={},j={};k.add=function(b){g[b.name]=b};k.util={xhr:function(b,a){var c=window.ActiveXObject?new window.ActiveXObject("Microsoft.XMLHTTP"):new window.XMLHttpRequest;c.open("GET",b,!0);c.onreadystatechange=function(){if(4===c.readyState)if(200===c.status)a(c.responseText);else throw Error("Could not load: "+b+", status = "+c.status);};return c.send(null)},globalEval:function(b){b&&/\S/.test(b)&&(window.execScript|| 2 | function(a){window.eval.call(window,a)})(b)}};(function(){var b=h._resolve;h._resolve=function(a,c){var d,e;if(e=a.match(/^(\w+)!(.+)$/))d=e[1],a=e[2];a="#"+i.parseAlias(a);if(!d&&(e=a.match(/[^?]*(\.\w+)/))){e=e[1];for(var f in g)if(g.hasOwnProperty(f)&&-1 2 | 3 | exports.Validators = 4 | is_array: (x) -> 5 | return Array.isArray(x) if Array.isArray 6 | Object.prototype.toString.call(x) == "[object Array]" 7 | 8 | is_string: (x) -> 9 | Object.prototype.toString.call(x) == "[object String]" 10 | 11 | is_number: (x) -> 12 | return true if Object.prototype.toString.call(x) == "[object Number]" 13 | 14 | if @is_string x 15 | regex = /^\-?[0-9]*\.?[0-9]+$/ 16 | return regex.test x 17 | 18 | false 19 | 20 | is_function: (x) -> 21 | Object.prototype.toString.call(x) == "[object Function]" 22 | 23 | is_object: (x) -> 24 | return false if Object.prototype.toString.call(x) != "[object Object]" 25 | 26 | for key of x 27 | break 28 | 29 | !key or Object.prototype.hasOwnProperty.call(x, key) 30 | 31 | is_email: (x) -> 32 | if @is_string x 33 | regex = /^[a-z0-9._%+-]+@[a-z0-9.-]+\.[a-z]{2,6}$/i 34 | return regex.test x 35 | false 36 | 37 | is_empty: (x) -> 38 | x = x.toString() if false == @is_string x 39 | 40 | return true if x == null 41 | return true if exports.Filters.trim(x) == "" 42 | false 43 | 44 | is_url: (x) -> 45 | /((http|https):\/\/(\w+:{0,1}\w*@)?(\S+)|)(:[0-9]+)?(\/|\/([\w#!:.?+=&%@!\-\/]))?/.test(x) 46 | 47 | is_ip: (x) -> 48 | octet = '(?:25[0-5]|2[0-4][0-9]|1[0-9]{2}|[1-9][0-9]|[0-9])'; 49 | ip = '(?:' + octet + '\\.){3}' + octet; 50 | quad = '(?:\\[' + ip + '\\])|(?:' + ip + ')'; 51 | regex = new RegExp( '(' + quad + ')' ); 52 | regex.test x 53 | 54 | is_whitespace: (x) -> 55 | x = x.toString() if false == @is_string x 56 | regex = /^\s*$/ 57 | regex.test(x) 58 | 59 | 60 | 61 | exports.Filters = 62 | trim: (x) -> 63 | x = x.toString() if false == exports.Validators.is_string x 64 | return x.trim() if String.prototype.trim 65 | 66 | if exports.Validators.is_whitespace "\xA0" 67 | trim_left = /^\s+/ 68 | trim_right = /\s+$/ 69 | else 70 | trim_left = /^[\s\xA0]+/ 71 | trim_right = /[\s\xA0]+$/ 72 | 73 | x.replace(trim_left, "").replace(trim_right, "") 74 | 75 | ucfirst: (x) -> 76 | return String(x).replace(/\b\w+\b/, (word) -> 77 | return word.substring(0,1).toUpperCase() + word.substring(1) 78 | ) 79 | 80 | to_text: (x) -> 81 | String(x).replace(/<[^>].*?>/g,"") 82 | 83 | to_number: (x) -> 84 | return Number x if exports.Validators.is_number x 85 | 0 86 | 87 | return 88 | 89 | -------------------------------------------------------------------------------- /static/sea-modules/xcat/1.0.0/xcat/utils.js: -------------------------------------------------------------------------------- 1 | // Generated by CoffeeScript 1.3.3 2 | (function() { 3 | 4 | define(function(require, exports) { 5 | exports.Validators = { 6 | is_array: function(x) { 7 | if (Array.isArray) { 8 | return Array.isArray(x); 9 | } 10 | return Object.prototype.toString.call(x) === "[object Array]"; 11 | }, 12 | is_string: function(x) { 13 | return Object.prototype.toString.call(x) === "[object String]"; 14 | }, 15 | is_number: function(x) { 16 | var regex; 17 | if (Object.prototype.toString.call(x) === "[object Number]") { 18 | return true; 19 | } 20 | if (this.is_string(x)) { 21 | regex = /^\-?[0-9]*\.?[0-9]+$/; 22 | return regex.test(x); 23 | } 24 | return false; 25 | }, 26 | is_function: function(x) { 27 | return Object.prototype.toString.call(x) === "[object Function]"; 28 | }, 29 | is_object: function(x) { 30 | var key; 31 | if (Object.prototype.toString.call(x) !== "[object Object]") { 32 | return false; 33 | } 34 | for (key in x) { 35 | break; 36 | } 37 | return !key || Object.prototype.hasOwnProperty.call(x, key); 38 | }, 39 | is_email: function(x) { 40 | var regex; 41 | if (this.is_string(x)) { 42 | regex = /^[a-z0-9._%+-]+@[a-z0-9.-]+\.[a-z]{2,6}$/i; 43 | return regex.test(x); 44 | } 45 | return false; 46 | }, 47 | is_empty: function(x) { 48 | if (false === this.is_string(x)) { 49 | x = x.toString(); 50 | } 51 | if (x === null) { 52 | return true; 53 | } 54 | if (exports.Filters.trim(x) === "") { 55 | return true; 56 | } 57 | return false; 58 | }, 59 | is_url: function(x) { 60 | return /((http|https):\/\/(\w+:{0,1}\w*@)?(\S+)|)(:[0-9]+)?(\/|\/([\w#!:.?+=&%@!\-\/]))?/.test(x); 61 | }, 62 | is_ip: function(x) { 63 | var ip, octet, quad, regex; 64 | octet = '(?:25[0-5]|2[0-4][0-9]|1[0-9]{2}|[1-9][0-9]|[0-9])'; 65 | ip = '(?:' + octet + '\\.){3}' + octet; 66 | quad = '(?:\\[' + ip + '\\])|(?:' + ip + ')'; 67 | regex = new RegExp('(' + quad + ')'); 68 | return regex.test(x); 69 | }, 70 | is_whitespace: function(x) { 71 | var regex; 72 | if (false === this.is_string(x)) { 73 | x = x.toString(); 74 | } 75 | regex = /^\s*$/; 76 | return regex.test(x); 77 | } 78 | }; 79 | exports.Filters = { 80 | trim: function(x) { 81 | var trim_left, trim_right; 82 | if (false === exports.Validators.is_string(x)) { 83 | x = x.toString(); 84 | } 85 | if (String.prototype.trim) { 86 | return x.trim(); 87 | } 88 | if (exports.Validators.is_whitespace("\xA0")) { 89 | trim_left = /^\s+/; 90 | trim_right = /\s+$/; 91 | } else { 92 | trim_left = /^[\s\xA0]+/; 93 | trim_right = /[\s\xA0]+$/; 94 | } 95 | return x.replace(trim_left, "").replace(trim_right, ""); 96 | }, 97 | ucfirst: function(x) { 98 | return String(x).replace(/\b\w+\b/, function(word) { 99 | return word.substring(0, 1).toUpperCase() + word.substring(1); 100 | }); 101 | }, 102 | to_text: function(x) { 103 | return String(x).replace(/<[^>].*?>/g, ""); 104 | }, 105 | to_number: function(x) { 106 | if (exports.Validators.is_number(x)) { 107 | return Number(x); 108 | } 109 | return 0; 110 | } 111 | }; 112 | }); 113 | 114 | }).call(this); 115 | -------------------------------------------------------------------------------- /static/storage/.DS_Store: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vfasky/BlogCatke/6bb4971c5af88f3edd88c6728561728f64316e18/static/storage/.DS_Store -------------------------------------------------------------------------------- /static/storage/file/.DS_Store: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vfasky/BlogCatke/6bb4971c5af88f3edd88c6728561728f64316e18/static/storage/file/.DS_Store -------------------------------------------------------------------------------- /static/storage/file/07ebdd0c535334dfd5a45904e1763208.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vfasky/BlogCatke/6bb4971c5af88f3edd88c6728561728f64316e18/static/storage/file/07ebdd0c535334dfd5a45904e1763208.png -------------------------------------------------------------------------------- /static/storage/file/279d5ff501fb7109df0f79d5467f2444.jpeg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vfasky/BlogCatke/6bb4971c5af88f3edd88c6728561728f64316e18/static/storage/file/279d5ff501fb7109df0f79d5467f2444.jpeg -------------------------------------------------------------------------------- /static/storage/file/54bd9433cbe5f4cac90ac9ec6ae9535c.jpeg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vfasky/BlogCatke/6bb4971c5af88f3edd88c6728561728f64316e18/static/storage/file/54bd9433cbe5f4cac90ac9ec6ae9535c.jpeg -------------------------------------------------------------------------------- /static/storage/file/5704442a7d7001f0796829f1954813b6.jpeg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vfasky/BlogCatke/6bb4971c5af88f3edd88c6728561728f64316e18/static/storage/file/5704442a7d7001f0796829f1954813b6.jpeg -------------------------------------------------------------------------------- /static/storage/file/71fbd74565221b196e7166531c29d5ce.jpeg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vfasky/BlogCatke/6bb4971c5af88f3edd88c6728561728f64316e18/static/storage/file/71fbd74565221b196e7166531c29d5ce.jpeg -------------------------------------------------------------------------------- /static/storage/file/85f0ee7a7ec25210853bd8ff9e4015ab.jpeg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vfasky/BlogCatke/6bb4971c5af88f3edd88c6728561728f64316e18/static/storage/file/85f0ee7a7ec25210853bd8ff9e4015ab.jpeg -------------------------------------------------------------------------------- /static/storage/file/97231b3b6e6a89d746d3c0399ec5d09d.jpeg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vfasky/BlogCatke/6bb4971c5af88f3edd88c6728561728f64316e18/static/storage/file/97231b3b6e6a89d746d3c0399ec5d09d.jpeg -------------------------------------------------------------------------------- /static/storage/file/a01687117c1fb2885f592e2c0c4ecd22.jpeg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vfasky/BlogCatke/6bb4971c5af88f3edd88c6728561728f64316e18/static/storage/file/a01687117c1fb2885f592e2c0c4ecd22.jpeg -------------------------------------------------------------------------------- /static/storage/file/af02f1681fdacf9af97a2f9a50a48295.jpeg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vfasky/BlogCatke/6bb4971c5af88f3edd88c6728561728f64316e18/static/storage/file/af02f1681fdacf9af97a2f9a50a48295.jpeg -------------------------------------------------------------------------------- /static/storage/file/b325c14b240d42133deb82eafff00e40.jpeg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vfasky/BlogCatke/6bb4971c5af88f3edd88c6728561728f64316e18/static/storage/file/b325c14b240d42133deb82eafff00e40.jpeg -------------------------------------------------------------------------------- /static/storage/file/c3dadc65d2c0a1aa2a33248f3808dd43.jpeg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vfasky/BlogCatke/6bb4971c5af88f3edd88c6728561728f64316e18/static/storage/file/c3dadc65d2c0a1aa2a33248f3808dd43.jpeg -------------------------------------------------------------------------------- /static/storage/file/d0dbf53812d6515a7e236fbccc0394a1.jpeg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vfasky/BlogCatke/6bb4971c5af88f3edd88c6728561728f64316e18/static/storage/file/d0dbf53812d6515a7e236fbccc0394a1.jpeg -------------------------------------------------------------------------------- /static/storage/file/f70bba3633421100b25938819a08d924.jpeg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vfasky/BlogCatke/6bb4971c5af88f3edd88c6728561728f64316e18/static/storage/file/f70bba3633421100b25938819a08d924.jpeg -------------------------------------------------------------------------------- /virtualenv.bundle/peewee.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vfasky/BlogCatke/6bb4971c5af88f3edd88c6728561728f64316e18/virtualenv.bundle/peewee.pyc -------------------------------------------------------------------------------- /virtualenv.bundle/playhouse/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vfasky/BlogCatke/6bb4971c5af88f3edd88c6728561728f64316e18/virtualenv.bundle/playhouse/__init__.py -------------------------------------------------------------------------------- /virtualenv.bundle/playhouse/apsw_ext.py: -------------------------------------------------------------------------------- 1 | import apsw 2 | from peewee import * 3 | from peewee import SqliteDatabase, Database, logger 4 | from peewee import BooleanField as _BooleanField, DateField as _DateField, TimeField as _TimeField, \ 5 | DateTimeField as _DateTimeField, DecimalField as _DecimalField, transaction as _transaction 6 | 7 | 8 | class ConnectionWrapper(apsw.Connection): 9 | def cursor(self): 10 | base_cursor = super(ConnectionWrapper, self).cursor() 11 | return CursorProxy(base_cursor) 12 | 13 | 14 | class CursorProxy(object): 15 | def __init__(self, cursor_obj): 16 | self.cursor_obj = cursor_obj 17 | self.implements = set(['description', 'fetchone']) 18 | 19 | def __getattr__(self, attr): 20 | if attr in self.implements: 21 | return self.__getattribute__(attr) 22 | return getattr(self.cursor_obj, attr) 23 | 24 | @property 25 | def description(self): 26 | try: 27 | return self.cursor_obj.getdescription() 28 | except apsw.ExecutionCompleteError: 29 | return [] 30 | 31 | def fetchone(self): 32 | try: 33 | return self.cursor_obj.next() 34 | except StopIteration: 35 | pass 36 | 37 | 38 | class transaction(_transaction): 39 | def __init__(self, db, lock_type='deferred'): 40 | self.db = db 41 | self.lock_type = lock_type 42 | 43 | def __enter__(self): 44 | self._orig = self.db.get_autocommit() 45 | self.db.set_autocommit(False) 46 | self.db.begin(self.lock_type) 47 | 48 | 49 | class APSWDatabase(SqliteDatabase): 50 | def __init__(self, database, timeout=None, **kwargs): 51 | self.timeout = timeout 52 | self._modules = {} 53 | super(APSWDatabase, self).__init__(database, **kwargs) 54 | 55 | def register_module(self, mod_name, mod_inst): 56 | self._modules[mod_name] = mod_inst 57 | 58 | def unregister_module(self, mod_name): 59 | del(self._modules[mod_name]) 60 | 61 | def _connect(self, database, **kwargs): 62 | conn = ConnectionWrapper(database, **kwargs) 63 | if self.timeout is not None: 64 | conn.setbusytimeout(self.timeout) 65 | for mod_name, mod_inst in self._modules.items(): 66 | conn.createmodule(mod_name, mod_inst) 67 | return conn 68 | 69 | def execute_sql(self, sql, params=None, require_commit=True): 70 | cursor = self.get_cursor() 71 | wrap_transaction = require_commit and self.get_autocommit() 72 | if wrap_transaction: 73 | cursor.execute('begin;') 74 | res = cursor.execute(sql, params or ()) 75 | if wrap_transaction: 76 | cursor.execute('commit;') 77 | logger.debug((sql, params)) 78 | return cursor 79 | 80 | def last_insert_id(self, cursor, model): 81 | return cursor.getconnection().last_insert_rowid() 82 | 83 | def rows_affected(self, cursor): 84 | return cursor.getconnection().changes() 85 | 86 | def begin(self, lock_type='deferred'): 87 | self.get_cursor().execute('begin %s;' % lock_type) 88 | 89 | def commit(self): 90 | self.get_cursor().execute('commit;') 91 | 92 | def rollback(self): 93 | self.get_cursor().execute('rollback;') 94 | 95 | def transaction(self, lock_type='deferred'): 96 | return transaction(self, lock_type) 97 | 98 | 99 | def nh(s, v): 100 | if v is not None: 101 | return str(v) 102 | 103 | class BooleanField(_BooleanField): 104 | def db_value(self, v): 105 | v = super(BooleanField, self).db_value(v) 106 | if v is not None: 107 | return v and 1 or 0 108 | 109 | class DateField(_DateField): 110 | db_value = nh 111 | 112 | class TimeField(_TimeField): 113 | db_value = nh 114 | 115 | class DateTimeField(_DateTimeField): 116 | db_value = nh 117 | 118 | class DecimalField(_DecimalField): 119 | db_value = nh 120 | -------------------------------------------------------------------------------- /virtualenv.bundle/playhouse/postgres_ext.py: -------------------------------------------------------------------------------- 1 | from peewee import * 2 | from peewee import QueryCompiler, Param, BinaryExpr, dict_update 3 | 4 | from psycopg2 import extensions 5 | from psycopg2.extras import register_hstore 6 | 7 | 8 | class HStoreField(Field): 9 | db_field = 'hash' 10 | 11 | def keys(self): 12 | return fn.akeys(self) 13 | 14 | def values(self): 15 | return fn.avals(self) 16 | 17 | def items(self): 18 | return fn.hstore_to_matrix(self) 19 | 20 | def slice(self, *args): 21 | return fn.slice(self, Param(list(args))) 22 | 23 | def exists(self, key): 24 | return fn.exist(self, key) 25 | 26 | def defined(self, key): 27 | return fn.defined(self, key) 28 | 29 | def update(self, **data): 30 | return BinaryExpr(self, OP_HUPDATE, data) 31 | 32 | def delete(self, *keys): 33 | return fn.delete(self, Param(list(keys))) 34 | 35 | def contains(self, value): 36 | if isinstance(value, dict): 37 | return Q(self, OP_HCONTAINS_DICT, Param(value)) 38 | elif isinstance(value, (list, tuple)): 39 | return Q(self, OP_HCONTAINS_KEYS, Param(value)) 40 | return Q(self, OP_HCONTAINS_KEY, value) 41 | 42 | 43 | OP_HUPDATE = 120 44 | OP_HCONTAINS_DICT = 121 45 | OP_HCONTAINS_KEYS = 122 46 | OP_HCONTAINS_KEY = 123 47 | 48 | 49 | class PostgresqlExtCompiler(QueryCompiler): 50 | def parse_create_index(self, model_class, fields, unique=False): 51 | parts = super(PostgresqlExtDatabase, self).parse_create_index( 52 | model_class, fields, unique) 53 | if any(lambda f: isinstance(f, HStore), fields): 54 | parts.insert(-1, 'USING GIST') 55 | return parts 56 | 57 | 58 | class PostgresqlExtDatabase(PostgresqlDatabase): 59 | compiler_class = PostgresqlExtCompiler 60 | expr_overrides = dict_update(PostgresqlDatabase.expr_overrides, { 61 | OP_HUPDATE: '||', 62 | }) 63 | field_overrides = dict_update(PostgresqlDatabase.field_overrides, { 64 | 'hash': 'hstore', 65 | }) 66 | op_overrides = dict_update(PostgresqlDatabase.op_overrides, { 67 | OP_HCONTAINS_DICT: '@>', 68 | OP_HCONTAINS_KEYS: '?&', 69 | OP_HCONTAINS_KEY: '?', 70 | }) 71 | 72 | def _connect(self, database, **kwargs): 73 | conn = super(PostgresqlExtDatabase, self)._connect(database, **kwargs) 74 | register_hstore(conn, globally=True) 75 | return conn 76 | -------------------------------------------------------------------------------- /virtualenv.bundle/playhouse/signals.py: -------------------------------------------------------------------------------- 1 | from peewee import Model as _Model 2 | 3 | 4 | class Signal(object): 5 | def __init__(self): 6 | self._flush() 7 | 8 | def connect(self, receiver, name=None, sender=None): 9 | name = name or receiver.__name__ 10 | if name not in self._receivers: 11 | self._receivers[name] = (receiver, sender) 12 | self._receiver_list.append(name) 13 | else: 14 | raise ValueError('receiver named %s already connected' % name) 15 | 16 | def disconnect(self, receiver=None, name=None): 17 | if receiver: 18 | name = receiver.__name__ 19 | if name: 20 | del self._receivers[name] 21 | self._receiver_list.remove(name) 22 | else: 23 | raise ValueError('a receiver or a name must be provided') 24 | 25 | def send(self, instance, *args, **kwargs): 26 | sender = type(instance) 27 | responses = [] 28 | for name in self._receiver_list: 29 | r, s = self._receivers[name] 30 | if s is None or sender is s: 31 | responses.append((r, r(sender, instance, *args, **kwargs))) 32 | return responses 33 | 34 | def _flush(self): 35 | self._receivers = {} 36 | self._receiver_list = [] 37 | 38 | 39 | pre_save = Signal() 40 | post_save = Signal() 41 | pre_delete = Signal() 42 | post_delete = Signal() 43 | pre_init = Signal() 44 | post_init = Signal() 45 | 46 | 47 | class Model(_Model): 48 | def __init__(self, *args, **kwargs): 49 | super(Model, self).__init__(*args, **kwargs) 50 | pre_init.send(self) 51 | 52 | def prepared(self): 53 | super(Model, self).prepared() 54 | post_init.send(self) 55 | 56 | def save(self, *args, **kwargs): 57 | created = not bool(self.get_id()) 58 | pre_save.send(self, created=created) 59 | super(Model, self).save(*args, **kwargs) 60 | post_save.send(self, created=created) 61 | 62 | def delete_instance(self, *args, **kwargs): 63 | pre_delete.send(self) 64 | super(Model, self).delete_instance(*args, **kwargs) 65 | post_delete.send(self) 66 | 67 | def connect(signal, name=None, sender=None): 68 | def decorator(fn): 69 | signal.connect(fn, name, sender) 70 | return fn 71 | return decorator 72 | -------------------------------------------------------------------------------- /virtualenv.bundle/playhouse/tests_apsw.py: -------------------------------------------------------------------------------- 1 | import apsw 2 | import datetime 3 | import unittest 4 | 5 | from apsw_ext import * 6 | 7 | 8 | db = APSWDatabase(':memory:') 9 | 10 | class BaseModel(Model): 11 | class Meta: 12 | database = db 13 | 14 | class User(BaseModel): 15 | username = CharField() 16 | 17 | class Message(BaseModel): 18 | user = ForeignKeyField(User) 19 | message = TextField() 20 | pub_date = DateTimeField() 21 | published = BooleanField() 22 | 23 | 24 | class APSWTestCase(unittest.TestCase): 25 | def setUp(self): 26 | Message.drop_table(True) 27 | User.drop_table(True) 28 | User.create_table() 29 | Message.create_table() 30 | 31 | def test_select_insert(self): 32 | users = ('u1', 'u2', 'u3') 33 | for user in users: 34 | User.create(username=user) 35 | 36 | self.assertEqual([x.username for x in User.select()], ['u1', 'u2', 'u3']) 37 | self.assertEqual([x.username for x in User.select().filter(username='x')], []) 38 | self.assertEqual([x.username for x in User.select().filter(username__in=['u1', 'u3'])], ['u1', 'u3']) 39 | 40 | dt = datetime.datetime(2012, 1, 1, 11, 11, 11) 41 | Message.create(user=User.get(username='u1'), message='herps', pub_date=dt, published=True) 42 | Message.create(user=User.get(username='u2'), message='derps', pub_date=dt, published=False) 43 | 44 | m1 = Message.get(message='herps') 45 | self.assertEqual(m1.user.username, 'u1') 46 | self.assertEqual(m1.pub_date, dt) 47 | self.assertEqual(m1.published, True) 48 | 49 | m2 = Message.get(message='derps') 50 | self.assertEqual(m2.user.username, 'u2') 51 | self.assertEqual(m2.pub_date, dt) 52 | self.assertEqual(m2.published, False) 53 | 54 | def test_update_delete(self): 55 | u1 = User.create(username='u1') 56 | u2 = User.create(username='u2') 57 | 58 | u1.username = 'u1-modified' 59 | u1.save() 60 | 61 | self.assertEqual(User.select().count(), 2) 62 | self.assertEqual(User.get(username='u1-modified').id, u1.id) 63 | 64 | u1.delete_instance() 65 | self.assertEqual(User.select().count(), 1) 66 | 67 | def test_transaction_handling(self): 68 | dt = datetime.datetime(2012, 01, 01, 11, 11, 11) 69 | 70 | def do_ctx_mgr_error(): 71 | with db.transaction(): 72 | User.create(username='u1') 73 | raise ValueError 74 | 75 | self.assertRaises(ValueError, do_ctx_mgr_error) 76 | self.assertEqual(User.select().count(), 0) 77 | 78 | def do_ctx_mgr_success(): 79 | with db.transaction(): 80 | u = User.create(username='test') 81 | Message.create(message='testing', user=u, pub_date=dt, published=1) 82 | 83 | do_ctx_mgr_success() 84 | self.assertEqual(User.select().count(), 1) 85 | self.assertEqual(Message.select().count(), 1) 86 | 87 | @db.commit_on_success 88 | def create_error(): 89 | u = User.create(username='test') 90 | Message.create(message='testing', user=u, pub_date=dt, published=1) 91 | raise ValueError 92 | 93 | self.assertRaises(ValueError, create_error) 94 | self.assertEqual(User.select().count(), 1) 95 | 96 | @db.commit_on_success 97 | def create_success(): 98 | u = User.create(username='test') 99 | Message.create(message='testing', user=u, pub_date=dt, published=1) 100 | 101 | create_success() 102 | self.assertEqual(User.select().count(), 2) 103 | self.assertEqual(Message.select().count(), 2) 104 | -------------------------------------------------------------------------------- /virtualenv.bundle/playhouse/tests_signals.py: -------------------------------------------------------------------------------- 1 | import unittest 2 | 3 | from peewee import * 4 | import signals 5 | 6 | 7 | db = SqliteDatabase(':memory:') 8 | 9 | class BaseSignalModel(signals.Model): 10 | class Meta: 11 | database = db 12 | 13 | class ModelA(BaseSignalModel): 14 | a = CharField(default='') 15 | 16 | class ModelB(BaseSignalModel): 17 | b = CharField(default='') 18 | 19 | 20 | class SignalsTestCase(unittest.TestCase): 21 | def setUp(self): 22 | ModelA.create_table(True) 23 | ModelB.create_table(True) 24 | 25 | def tearDown(self): 26 | ModelA.drop_table() 27 | ModelB.drop_table() 28 | signals.pre_save._flush() 29 | signals.post_save._flush() 30 | signals.pre_delete._flush() 31 | signals.post_delete._flush() 32 | signals.pre_init._flush() 33 | signals.post_init._flush() 34 | 35 | def test_pre_save(self): 36 | state = [] 37 | 38 | @signals.connect(signals.pre_save) 39 | def pre_save(sender, instance, created): 40 | state.append((sender, instance, instance.get_id(), created)) 41 | m = ModelA() 42 | m.save() 43 | self.assertEqual(state, [(ModelA, m, None, True)]) 44 | 45 | m.save() 46 | self.assertTrue(m.id is not None) 47 | self.assertEqual(state[-1], (ModelA, m, m.id, False)) 48 | 49 | def test_post_save(self): 50 | state = [] 51 | 52 | @signals.connect(signals.post_save) 53 | def post_save(sender, instance, created): 54 | state.append((sender, instance, instance.get_id(), created)) 55 | m = ModelA() 56 | m.save() 57 | 58 | self.assertTrue(m.id is not None) 59 | self.assertEqual(state, [(ModelA, m, m.id, True)]) 60 | 61 | m.save() 62 | self.assertEqual(state[-1], (ModelA, m, m.id, False)) 63 | 64 | def test_pre_delete(self): 65 | state = [] 66 | 67 | m = ModelA() 68 | m.save() 69 | 70 | @signals.connect(signals.pre_delete) 71 | def pre_delete(sender, instance): 72 | state.append((sender, instance, ModelA.select().count())) 73 | m.delete_instance() 74 | self.assertEqual(state, [(ModelA, m, 1)]) 75 | 76 | def test_post_delete(self): 77 | state = [] 78 | 79 | m = ModelA() 80 | m.save() 81 | 82 | @signals.connect(signals.post_delete) 83 | def post_delete(sender, instance): 84 | state.append((sender, instance, ModelA.select().count())) 85 | m.delete_instance() 86 | self.assertEqual(state, [(ModelA, m, 0)]) 87 | 88 | def test_pre_init(self): 89 | state = [] 90 | 91 | m = ModelA(a='a') 92 | m.save() 93 | 94 | @signals.connect(signals.pre_init) 95 | def pre_init(sender, instance): 96 | state.append((sender, instance.a)) 97 | 98 | ModelA.get() 99 | self.assertEqual(state, [(ModelA, '')]) 100 | 101 | def test_post_init(self): 102 | state = [] 103 | 104 | m = ModelA(a='a') 105 | m.save() 106 | 107 | @signals.connect(signals.post_init) 108 | def post_init(sender, instance): 109 | state.append((sender, instance.a)) 110 | 111 | ModelA.get() 112 | self.assertEqual(state, [(ModelA, 'a')]) 113 | 114 | def test_sender(self): 115 | state = [] 116 | 117 | @signals.connect(signals.post_save, sender=ModelA) 118 | def post_save(sender, instance, created): 119 | state.append(instance) 120 | 121 | m = ModelA.create() 122 | self.assertEqual(state, [m]) 123 | 124 | m2 = ModelB.create() 125 | self.assertEqual(state, [m]) 126 | 127 | def test_connect_disconnect(self): 128 | state = [] 129 | 130 | @signals.connect(signals.post_save, sender=ModelA) 131 | def post_save(sender, instance, created): 132 | state.append(instance) 133 | 134 | m = ModelA.create() 135 | self.assertEqual(state, [m]) 136 | 137 | signals.post_save.disconnect(post_save) 138 | m2 = ModelA.create() 139 | self.assertEqual(state, [m]) 140 | -------------------------------------------------------------------------------- /virtualenv.bundle/requests/__init__.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | 3 | # __ 4 | # /__) _ _ _ _ _/ _ 5 | # / ( (- (/ (/ (- _) / _) 6 | # / 7 | 8 | """ 9 | requests HTTP library 10 | ~~~~~~~~~~~~~~~~~~~~~ 11 | 12 | Requests is an HTTP library, written in Python, for human beings. Basic GET 13 | usage: 14 | 15 | >>> import requests 16 | >>> r = requests.get('http://python.org') 17 | >>> r.status_code 18 | 200 19 | >>> 'Python is a programming language' in r.content 20 | True 21 | 22 | ... or POST: 23 | 24 | >>> payload = dict(key1='value1', key2='value2') 25 | >>> r = requests.post("http://httpbin.org/post", data=payload) 26 | >>> print r.text 27 | { 28 | ... 29 | "form": { 30 | "key2": "value2", 31 | "key1": "value1" 32 | }, 33 | ... 34 | } 35 | 36 | The other HTTP methods are supported - see `requests.api`. Full documentation 37 | is at . 38 | 39 | :copyright: (c) 2012 by Kenneth Reitz. 40 | :license: ISC, see LICENSE for more details. 41 | 42 | """ 43 | 44 | __title__ = 'requests' 45 | __version__ = '0.14.1' 46 | __build__ = 0x001401 47 | __author__ = 'Kenneth Reitz' 48 | __license__ = 'ISC' 49 | __copyright__ = 'Copyright 2012 Kenneth Reitz' 50 | 51 | 52 | from . import utils 53 | from .models import Request, Response 54 | from .api import request, get, head, post, patch, put, delete, options 55 | from .sessions import session, Session 56 | from .status_codes import codes 57 | from .exceptions import ( 58 | RequestException, Timeout, URLRequired, 59 | TooManyRedirects, HTTPError, ConnectionError 60 | ) 61 | -------------------------------------------------------------------------------- /virtualenv.bundle/requests/__init__.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vfasky/BlogCatke/6bb4971c5af88f3edd88c6728561728f64316e18/virtualenv.bundle/requests/__init__.pyc -------------------------------------------------------------------------------- /virtualenv.bundle/requests/_oauth.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | 3 | """ 4 | requests._oauth 5 | ~~~~~~~~~~~~~~~ 6 | 7 | This module contains the path hack necessary for oauthlib to be vendored into 8 | requests while allowing upstream changes. 9 | """ 10 | 11 | import os 12 | import sys 13 | 14 | try: 15 | from oauthlib.oauth1 import rfc5849 16 | from oauthlib.common import extract_params 17 | from oauthlib.oauth1.rfc5849 import (Client, SIGNATURE_HMAC, SIGNATURE_TYPE_AUTH_HEADER) 18 | except ImportError: 19 | directory = os.path.dirname(__file__) 20 | path = os.path.join(directory, 'packages') 21 | sys.path.insert(0, path) 22 | from oauthlib.oauth1 import rfc5849 23 | from oauthlib.common import extract_params 24 | from oauthlib.oauth1.rfc5849 import (Client, SIGNATURE_HMAC, SIGNATURE_TYPE_AUTH_HEADER) 25 | -------------------------------------------------------------------------------- /virtualenv.bundle/requests/_oauth.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vfasky/BlogCatke/6bb4971c5af88f3edd88c6728561728f64316e18/virtualenv.bundle/requests/_oauth.pyc -------------------------------------------------------------------------------- /virtualenv.bundle/requests/api.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vfasky/BlogCatke/6bb4971c5af88f3edd88c6728561728f64316e18/virtualenv.bundle/requests/api.pyc -------------------------------------------------------------------------------- /virtualenv.bundle/requests/async.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vfasky/BlogCatke/6bb4971c5af88f3edd88c6728561728f64316e18/virtualenv.bundle/requests/async.py -------------------------------------------------------------------------------- /virtualenv.bundle/requests/auth.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vfasky/BlogCatke/6bb4971c5af88f3edd88c6728561728f64316e18/virtualenv.bundle/requests/auth.pyc -------------------------------------------------------------------------------- /virtualenv.bundle/requests/certs.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | # -*- coding: utf-8 -*- 3 | 4 | """ 5 | ceritfi.py 6 | ~~~~~~~~~~ 7 | 8 | This module returns the installation location of cacert.pem. 9 | """ 10 | 11 | import os 12 | try: 13 | import certifi 14 | except ImportError: 15 | certifi = None 16 | 17 | 18 | def where(): 19 | 20 | if certifi: 21 | return certifi.where() 22 | else: 23 | f = os.path.split(__file__)[0] 24 | return os.path.join(f, 'cacert.pem') 25 | 26 | if __name__ == '__main__': 27 | print(where()) 28 | -------------------------------------------------------------------------------- /virtualenv.bundle/requests/certs.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vfasky/BlogCatke/6bb4971c5af88f3edd88c6728561728f64316e18/virtualenv.bundle/requests/certs.pyc -------------------------------------------------------------------------------- /virtualenv.bundle/requests/compat.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | 3 | """ 4 | pythoncompat 5 | """ 6 | 7 | 8 | import sys 9 | 10 | # ------- 11 | # Pythons 12 | # ------- 13 | 14 | # Syntax sugar. 15 | _ver = sys.version_info 16 | 17 | #: Python 2.x? 18 | is_py2 = (_ver[0] == 2) 19 | 20 | #: Python 3.x? 21 | is_py3 = (_ver[0] == 3) 22 | 23 | #: Python 3.0.x 24 | is_py30 = (is_py3 and _ver[1] == 0) 25 | 26 | #: Python 3.1.x 27 | is_py31 = (is_py3 and _ver[1] == 1) 28 | 29 | #: Python 3.2.x 30 | is_py32 = (is_py3 and _ver[1] == 2) 31 | 32 | #: Python 3.3.x 33 | is_py33 = (is_py3 and _ver[1] == 3) 34 | 35 | #: Python 3.4.x 36 | is_py34 = (is_py3 and _ver[1] == 4) 37 | 38 | #: Python 2.7.x 39 | is_py27 = (is_py2 and _ver[1] == 7) 40 | 41 | #: Python 2.6.x 42 | is_py26 = (is_py2 and _ver[1] == 6) 43 | 44 | #: Python 2.5.x 45 | is_py25 = (is_py2 and _ver[1] == 5) 46 | 47 | #: Python 2.4.x 48 | is_py24 = (is_py2 and _ver[1] == 4) # I'm assuming this is not by choice. 49 | 50 | 51 | # --------- 52 | # Platforms 53 | # --------- 54 | 55 | 56 | # Syntax sugar. 57 | _ver = sys.version.lower() 58 | 59 | is_pypy = ('pypy' in _ver) 60 | is_jython = ('jython' in _ver) 61 | is_ironpython = ('iron' in _ver) 62 | 63 | # Assume CPython, if nothing else. 64 | is_cpython = not any((is_pypy, is_jython, is_ironpython)) 65 | 66 | # Windows-based system. 67 | is_windows = 'win32' in str(sys.platform).lower() 68 | 69 | # Standard Linux 2+ system. 70 | is_linux = ('linux' in str(sys.platform).lower()) 71 | is_osx = ('darwin' in str(sys.platform).lower()) 72 | is_hpux = ('hpux' in str(sys.platform).lower()) # Complete guess. 73 | is_solaris = ('solar==' in str(sys.platform).lower()) # Complete guess. 74 | 75 | try: 76 | import simplejson as json 77 | except ImportError: 78 | import json 79 | 80 | # --------- 81 | # Specifics 82 | # --------- 83 | 84 | 85 | if is_py2: 86 | from urllib import quote, unquote, urlencode 87 | from urlparse import urlparse, urlunparse, urljoin, urlsplit 88 | from urllib2 import parse_http_list 89 | import cookielib 90 | from Cookie import Morsel 91 | from StringIO import StringIO 92 | try: 93 | import cchardet as chardet 94 | except ImportError: 95 | from .packages import chardet 96 | from .packages.urllib3.packages.ordered_dict import OrderedDict 97 | 98 | builtin_str = str 99 | bytes = str 100 | str = unicode 101 | basestring = basestring 102 | numeric_types = (int, long, float) 103 | 104 | 105 | 106 | elif is_py3: 107 | from urllib.parse import urlparse, urlunparse, urljoin, urlsplit, urlencode, quote, unquote 108 | from urllib.request import parse_http_list 109 | from http import cookiejar as cookielib 110 | from http.cookies import Morsel 111 | from io import StringIO 112 | from .packages import chardet2 as chardet 113 | from collections import OrderedDict 114 | 115 | builtin_str = str 116 | str = str 117 | bytes = bytes 118 | basestring = (str,bytes) 119 | numeric_types = (int, float) 120 | -------------------------------------------------------------------------------- /virtualenv.bundle/requests/compat.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vfasky/BlogCatke/6bb4971c5af88f3edd88c6728561728f64316e18/virtualenv.bundle/requests/compat.pyc -------------------------------------------------------------------------------- /virtualenv.bundle/requests/cookies.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vfasky/BlogCatke/6bb4971c5af88f3edd88c6728561728f64316e18/virtualenv.bundle/requests/cookies.pyc -------------------------------------------------------------------------------- /virtualenv.bundle/requests/defaults.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | 3 | """ 4 | requests.defaults 5 | ~~~~~~~~~~~~~~~~~ 6 | 7 | This module provides the Requests configuration defaults. 8 | 9 | Configurations: 10 | 11 | :base_headers: Default HTTP headers. 12 | :verbose: Stream to write request logging to. 13 | :max_redirects: Maximum number of redirects allowed within a request.s 14 | :keep_alive: Reuse HTTP Connections? 15 | :max_retries: The number of times a request should be retried in the event of a connection failure. 16 | :danger_mode: If true, Requests will raise errors immediately. 17 | :safe_mode: If true, Requests will catch all errors. 18 | :strict_mode: If true, Requests will do its best to follow RFCs (e.g. POST redirects). 19 | :pool_maxsize: The maximium size of an HTTP connection pool. 20 | :pool_connections: The number of active HTTP connection pools to use. 21 | :encode_uri: If true, URIs will automatically be percent-encoded. 22 | :trust_env: If true, the surrouding environment will be trusted (environ, netrc). 23 | :store_cookies: If false, the received cookies as part of the HTTP response would be ignored. 24 | 25 | """ 26 | 27 | SCHEMAS = ['http', 'https'] 28 | 29 | from .utils import default_user_agent 30 | 31 | defaults = dict() 32 | 33 | defaults['base_headers'] = { 34 | 'User-Agent': default_user_agent(), 35 | 'Accept-Encoding': ', '.join(('gzip', 'deflate', 'compress')), 36 | 'Accept': '*/*' 37 | } 38 | 39 | defaults['verbose'] = None 40 | defaults['max_redirects'] = 30 41 | defaults['pool_connections'] = 10 42 | defaults['pool_maxsize'] = 10 43 | defaults['max_retries'] = 0 44 | defaults['danger_mode'] = False 45 | defaults['safe_mode'] = False 46 | defaults['strict_mode'] = False 47 | defaults['keep_alive'] = True 48 | defaults['encode_uri'] = True 49 | defaults['trust_env'] = True 50 | defaults['store_cookies'] = True 51 | -------------------------------------------------------------------------------- /virtualenv.bundle/requests/defaults.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vfasky/BlogCatke/6bb4971c5af88f3edd88c6728561728f64316e18/virtualenv.bundle/requests/defaults.pyc -------------------------------------------------------------------------------- /virtualenv.bundle/requests/exceptions.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | 3 | """ 4 | requests.exceptions 5 | ~~~~~~~~~~~~~~~~~~~ 6 | 7 | This module contains the set of Requests' exceptions. 8 | 9 | """ 10 | 11 | 12 | class RequestException(RuntimeError): 13 | """There was an ambiguous exception that occurred while handling your 14 | request.""" 15 | 16 | 17 | class HTTPError(RequestException): 18 | """An HTTP error occurred.""" 19 | response = None 20 | 21 | 22 | class ConnectionError(RequestException): 23 | """A Connection error occurred.""" 24 | 25 | 26 | class SSLError(ConnectionError): 27 | """An SSL error occurred.""" 28 | 29 | 30 | class Timeout(RequestException): 31 | """The request timed out.""" 32 | 33 | 34 | class URLRequired(RequestException): 35 | """A valid URL is required to make a request.""" 36 | 37 | 38 | class TooManyRedirects(RequestException): 39 | """Too many redirects.""" 40 | 41 | 42 | class MissingSchema(RequestException, ValueError): 43 | """The URL schema (e.g. http or https) is missing.""" 44 | 45 | 46 | class InvalidSchema(RequestException, ValueError): 47 | """See defaults.py for valid schemas.""" 48 | 49 | 50 | class InvalidURL(RequestException, ValueError): 51 | """ The URL provided was somehow invalid. """ 52 | -------------------------------------------------------------------------------- /virtualenv.bundle/requests/exceptions.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vfasky/BlogCatke/6bb4971c5af88f3edd88c6728561728f64316e18/virtualenv.bundle/requests/exceptions.pyc -------------------------------------------------------------------------------- /virtualenv.bundle/requests/hooks.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | 3 | """ 4 | requests.hooks 5 | ~~~~~~~~~~~~~~ 6 | 7 | This module provides the capabilities for the Requests hooks system. 8 | 9 | Available hooks: 10 | 11 | ``args``: 12 | A dictionary of the arguments being sent to Request(). 13 | 14 | ``pre_request``: 15 | The Request object, directly after being created. 16 | 17 | ``pre_send``: 18 | The Request object, directly before being sent. 19 | 20 | ``post_request``: 21 | The Request object, directly after being sent. 22 | 23 | ``response``: 24 | The response generated from a Request. 25 | 26 | """ 27 | 28 | 29 | HOOKS = ('args', 'pre_request', 'pre_send', 'post_request', 'response') 30 | 31 | 32 | def dispatch_hook(key, hooks, hook_data): 33 | """Dispatches a hook dictionary on a given piece of data.""" 34 | 35 | hooks = hooks or dict() 36 | 37 | if key in hooks: 38 | hooks = hooks.get(key) 39 | 40 | if hasattr(hooks, '__call__'): 41 | hooks = [hooks] 42 | 43 | for hook in hooks: 44 | _hook_data = hook(hook_data) 45 | if _hook_data is not None: 46 | hook_data = _hook_data 47 | 48 | 49 | return hook_data 50 | -------------------------------------------------------------------------------- /virtualenv.bundle/requests/hooks.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vfasky/BlogCatke/6bb4971c5af88f3edd88c6728561728f64316e18/virtualenv.bundle/requests/hooks.pyc -------------------------------------------------------------------------------- /virtualenv.bundle/requests/models.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vfasky/BlogCatke/6bb4971c5af88f3edd88c6728561728f64316e18/virtualenv.bundle/requests/models.pyc -------------------------------------------------------------------------------- /virtualenv.bundle/requests/packages/__init__.py: -------------------------------------------------------------------------------- 1 | from __future__ import absolute_import 2 | 3 | from . import urllib3 4 | -------------------------------------------------------------------------------- /virtualenv.bundle/requests/packages/__init__.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vfasky/BlogCatke/6bb4971c5af88f3edd88c6728561728f64316e18/virtualenv.bundle/requests/packages/__init__.pyc -------------------------------------------------------------------------------- /virtualenv.bundle/requests/packages/chardet/__init__.py: -------------------------------------------------------------------------------- 1 | ######################## BEGIN LICENSE BLOCK ######################## 2 | # This library is free software; you can redistribute it and/or 3 | # modify it under the terms of the GNU Lesser General Public 4 | # License as published by the Free Software Foundation; either 5 | # version 2.1 of the License, or (at your option) any later version. 6 | # 7 | # This library is distributed in the hope that it will be useful, 8 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 9 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 10 | # Lesser General Public License for more details. 11 | # 12 | # You should have received a copy of the GNU Lesser General Public 13 | # License along with this library; if not, write to the Free Software 14 | # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 15 | # 02110-1301 USA 16 | ######################### END LICENSE BLOCK ######################### 17 | 18 | __version__ = "1.0.1" 19 | 20 | def detect(aBuf): 21 | import universaldetector 22 | u = universaldetector.UniversalDetector() 23 | u.reset() 24 | u.feed(aBuf) 25 | u.close() 26 | return u.result 27 | -------------------------------------------------------------------------------- /virtualenv.bundle/requests/packages/chardet/__init__.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vfasky/BlogCatke/6bb4971c5af88f3edd88c6728561728f64316e18/virtualenv.bundle/requests/packages/chardet/__init__.pyc -------------------------------------------------------------------------------- /virtualenv.bundle/requests/packages/chardet/big5prober.py: -------------------------------------------------------------------------------- 1 | ######################## BEGIN LICENSE BLOCK ######################## 2 | # The Original Code is Mozilla Communicator client code. 3 | # 4 | # The Initial Developer of the Original Code is 5 | # Netscape Communications Corporation. 6 | # Portions created by the Initial Developer are Copyright (C) 1998 7 | # the Initial Developer. All Rights Reserved. 8 | # 9 | # Contributor(s): 10 | # Mark Pilgrim - port to Python 11 | # 12 | # This library is free software; you can redistribute it and/or 13 | # modify it under the terms of the GNU Lesser General Public 14 | # License as published by the Free Software Foundation; either 15 | # version 2.1 of the License, or (at your option) any later version. 16 | # 17 | # This library is distributed in the hope that it will be useful, 18 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 19 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 20 | # Lesser General Public License for more details. 21 | # 22 | # You should have received a copy of the GNU Lesser General Public 23 | # License along with this library; if not, write to the Free Software 24 | # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 25 | # 02110-1301 USA 26 | ######################### END LICENSE BLOCK ######################### 27 | 28 | from mbcharsetprober import MultiByteCharSetProber 29 | from codingstatemachine import CodingStateMachine 30 | from chardistribution import Big5DistributionAnalysis 31 | from mbcssm import Big5SMModel 32 | 33 | class Big5Prober(MultiByteCharSetProber): 34 | def __init__(self): 35 | MultiByteCharSetProber.__init__(self) 36 | self._mCodingSM = CodingStateMachine(Big5SMModel) 37 | self._mDistributionAnalyzer = Big5DistributionAnalysis() 38 | self.reset() 39 | 40 | def get_charset_name(self): 41 | return "Big5" 42 | -------------------------------------------------------------------------------- /virtualenv.bundle/requests/packages/chardet/charsetgroupprober.py: -------------------------------------------------------------------------------- 1 | ######################## BEGIN LICENSE BLOCK ######################## 2 | # The Original Code is Mozilla Communicator client code. 3 | # 4 | # The Initial Developer of the Original Code is 5 | # Netscape Communications Corporation. 6 | # Portions created by the Initial Developer are Copyright (C) 1998 7 | # the Initial Developer. All Rights Reserved. 8 | # 9 | # Contributor(s): 10 | # Mark Pilgrim - port to Python 11 | # 12 | # This library is free software; you can redistribute it and/or 13 | # modify it under the terms of the GNU Lesser General Public 14 | # License as published by the Free Software Foundation; either 15 | # version 2.1 of the License, or (at your option) any later version. 16 | # 17 | # This library is distributed in the hope that it will be useful, 18 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 19 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 20 | # Lesser General Public License for more details. 21 | # 22 | # You should have received a copy of the GNU Lesser General Public 23 | # License along with this library; if not, write to the Free Software 24 | # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 25 | # 02110-1301 USA 26 | ######################### END LICENSE BLOCK ######################### 27 | 28 | import constants, sys 29 | from charsetprober import CharSetProber 30 | 31 | class CharSetGroupProber(CharSetProber): 32 | def __init__(self): 33 | CharSetProber.__init__(self) 34 | self._mActiveNum = 0 35 | self._mProbers = [] 36 | self._mBestGuessProber = None 37 | 38 | def reset(self): 39 | CharSetProber.reset(self) 40 | self._mActiveNum = 0 41 | for prober in self._mProbers: 42 | if prober: 43 | prober.reset() 44 | prober.active = constants.True 45 | self._mActiveNum += 1 46 | self._mBestGuessProber = None 47 | 48 | def get_charset_name(self): 49 | if not self._mBestGuessProber: 50 | self.get_confidence() 51 | if not self._mBestGuessProber: return None 52 | # self._mBestGuessProber = self._mProbers[0] 53 | return self._mBestGuessProber.get_charset_name() 54 | 55 | def feed(self, aBuf): 56 | for prober in self._mProbers: 57 | if not prober: continue 58 | if not prober.active: continue 59 | st = prober.feed(aBuf) 60 | if not st: continue 61 | if st == constants.eFoundIt: 62 | self._mBestGuessProber = prober 63 | return self.get_state() 64 | elif st == constants.eNotMe: 65 | prober.active = constants.False 66 | self._mActiveNum -= 1 67 | if self._mActiveNum <= 0: 68 | self._mState = constants.eNotMe 69 | return self.get_state() 70 | return self.get_state() 71 | 72 | def get_confidence(self): 73 | st = self.get_state() 74 | if st == constants.eFoundIt: 75 | return 0.99 76 | elif st == constants.eNotMe: 77 | return 0.01 78 | bestConf = 0.0 79 | self._mBestGuessProber = None 80 | for prober in self._mProbers: 81 | if not prober: continue 82 | if not prober.active: 83 | if constants._debug: 84 | sys.stderr.write(prober.get_charset_name() + ' not active\n') 85 | continue 86 | cf = prober.get_confidence() 87 | if constants._debug: 88 | sys.stderr.write('%s confidence = %s\n' % (prober.get_charset_name(), cf)) 89 | if bestConf < cf: 90 | bestConf = cf 91 | self._mBestGuessProber = prober 92 | if not self._mBestGuessProber: return 0.0 93 | return bestConf 94 | # else: 95 | # self._mBestGuessProber = self._mProbers[0] 96 | # return self._mBestGuessProber.get_confidence() 97 | -------------------------------------------------------------------------------- /virtualenv.bundle/requests/packages/chardet/charsetprober.py: -------------------------------------------------------------------------------- 1 | ######################## BEGIN LICENSE BLOCK ######################## 2 | # The Original Code is Mozilla Universal charset detector code. 3 | # 4 | # The Initial Developer of the Original Code is 5 | # Netscape Communications Corporation. 6 | # Portions created by the Initial Developer are Copyright (C) 2001 7 | # the Initial Developer. All Rights Reserved. 8 | # 9 | # Contributor(s): 10 | # Mark Pilgrim - port to Python 11 | # Shy Shalom - original C code 12 | # 13 | # This library is free software; you can redistribute it and/or 14 | # modify it under the terms of the GNU Lesser General Public 15 | # License as published by the Free Software Foundation; either 16 | # version 2.1 of the License, or (at your option) any later version. 17 | # 18 | # This library is distributed in the hope that it will be useful, 19 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 20 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 21 | # Lesser General Public License for more details. 22 | # 23 | # You should have received a copy of the GNU Lesser General Public 24 | # License along with this library; if not, write to the Free Software 25 | # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 26 | # 02110-1301 USA 27 | ######################### END LICENSE BLOCK ######################### 28 | 29 | import constants, re 30 | 31 | class CharSetProber: 32 | def __init__(self): 33 | pass 34 | 35 | def reset(self): 36 | self._mState = constants.eDetecting 37 | 38 | def get_charset_name(self): 39 | return None 40 | 41 | def feed(self, aBuf): 42 | pass 43 | 44 | def get_state(self): 45 | return self._mState 46 | 47 | def get_confidence(self): 48 | return 0.0 49 | 50 | def filter_high_bit_only(self, aBuf): 51 | aBuf = re.sub(r'([\x00-\x7F])+', ' ', aBuf) 52 | return aBuf 53 | 54 | def filter_without_english_letters(self, aBuf): 55 | aBuf = re.sub(r'([A-Za-z])+', ' ', aBuf) 56 | return aBuf 57 | 58 | def filter_with_english_letters(self, aBuf): 59 | # TODO 60 | return aBuf 61 | -------------------------------------------------------------------------------- /virtualenv.bundle/requests/packages/chardet/codingstatemachine.py: -------------------------------------------------------------------------------- 1 | ######################## BEGIN LICENSE BLOCK ######################## 2 | # The Original Code is mozilla.org code. 3 | # 4 | # The Initial Developer of the Original Code is 5 | # Netscape Communications Corporation. 6 | # Portions created by the Initial Developer are Copyright (C) 1998 7 | # the Initial Developer. All Rights Reserved. 8 | # 9 | # Contributor(s): 10 | # Mark Pilgrim - port to Python 11 | # 12 | # This library is free software; you can redistribute it and/or 13 | # modify it under the terms of the GNU Lesser General Public 14 | # License as published by the Free Software Foundation; either 15 | # version 2.1 of the License, or (at your option) any later version. 16 | # 17 | # This library is distributed in the hope that it will be useful, 18 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 19 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 20 | # Lesser General Public License for more details. 21 | # 22 | # You should have received a copy of the GNU Lesser General Public 23 | # License along with this library; if not, write to the Free Software 24 | # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 25 | # 02110-1301 USA 26 | ######################### END LICENSE BLOCK ######################### 27 | 28 | from constants import eStart, eError, eItsMe 29 | 30 | class CodingStateMachine: 31 | def __init__(self, sm): 32 | self._mModel = sm 33 | self._mCurrentBytePos = 0 34 | self._mCurrentCharLen = 0 35 | self.reset() 36 | 37 | def reset(self): 38 | self._mCurrentState = eStart 39 | 40 | def next_state(self, c): 41 | # for each byte we get its class 42 | # if it is first byte, we also get byte length 43 | byteCls = self._mModel['classTable'][ord(c)] 44 | if self._mCurrentState == eStart: 45 | self._mCurrentBytePos = 0 46 | self._mCurrentCharLen = self._mModel['charLenTable'][byteCls] 47 | # from byte's class and stateTable, we get its next state 48 | self._mCurrentState = self._mModel['stateTable'][self._mCurrentState * self._mModel['classFactor'] + byteCls] 49 | self._mCurrentBytePos += 1 50 | return self._mCurrentState 51 | 52 | def get_current_charlen(self): 53 | return self._mCurrentCharLen 54 | 55 | def get_coding_state_machine(self): 56 | return self._mModel['name'] 57 | -------------------------------------------------------------------------------- /virtualenv.bundle/requests/packages/chardet/constants.py: -------------------------------------------------------------------------------- 1 | ######################## BEGIN LICENSE BLOCK ######################## 2 | # The Original Code is Mozilla Universal charset detector code. 3 | # 4 | # The Initial Developer of the Original Code is 5 | # Netscape Communications Corporation. 6 | # Portions created by the Initial Developer are Copyright (C) 2001 7 | # the Initial Developer. All Rights Reserved. 8 | # 9 | # Contributor(s): 10 | # Mark Pilgrim - port to Python 11 | # Shy Shalom - original C code 12 | # 13 | # This library is free software; you can redistribute it and/or 14 | # modify it under the terms of the GNU Lesser General Public 15 | # License as published by the Free Software Foundation; either 16 | # version 2.1 of the License, or (at your option) any later version. 17 | # 18 | # This library is distributed in the hope that it will be useful, 19 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 20 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 21 | # Lesser General Public License for more details. 22 | # 23 | # You should have received a copy of the GNU Lesser General Public 24 | # License along with this library; if not, write to the Free Software 25 | # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 26 | # 02110-1301 USA 27 | ######################### END LICENSE BLOCK ######################### 28 | 29 | _debug = 0 30 | 31 | eDetecting = 0 32 | eFoundIt = 1 33 | eNotMe = 2 34 | 35 | eStart = 0 36 | eError = 1 37 | eItsMe = 2 38 | 39 | SHORTCUT_THRESHOLD = 0.95 40 | 41 | import __builtin__ 42 | if not hasattr(__builtin__, 'False'): 43 | False = 0 44 | True = 1 45 | else: 46 | False = __builtin__.False 47 | True = __builtin__.True 48 | -------------------------------------------------------------------------------- /virtualenv.bundle/requests/packages/chardet/escprober.py: -------------------------------------------------------------------------------- 1 | ######################## BEGIN LICENSE BLOCK ######################## 2 | # The Original Code is mozilla.org code. 3 | # 4 | # The Initial Developer of the Original Code is 5 | # Netscape Communications Corporation. 6 | # Portions created by the Initial Developer are Copyright (C) 1998 7 | # the Initial Developer. All Rights Reserved. 8 | # 9 | # Contributor(s): 10 | # Mark Pilgrim - port to Python 11 | # 12 | # This library is free software; you can redistribute it and/or 13 | # modify it under the terms of the GNU Lesser General Public 14 | # License as published by the Free Software Foundation; either 15 | # version 2.1 of the License, or (at your option) any later version. 16 | # 17 | # This library is distributed in the hope that it will be useful, 18 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 19 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 20 | # Lesser General Public License for more details. 21 | # 22 | # You should have received a copy of the GNU Lesser General Public 23 | # License along with this library; if not, write to the Free Software 24 | # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 25 | # 02110-1301 USA 26 | ######################### END LICENSE BLOCK ######################### 27 | 28 | import constants, sys 29 | from escsm import HZSMModel, ISO2022CNSMModel, ISO2022JPSMModel, ISO2022KRSMModel 30 | from charsetprober import CharSetProber 31 | from codingstatemachine import CodingStateMachine 32 | 33 | class EscCharSetProber(CharSetProber): 34 | def __init__(self): 35 | CharSetProber.__init__(self) 36 | self._mCodingSM = [ \ 37 | CodingStateMachine(HZSMModel), 38 | CodingStateMachine(ISO2022CNSMModel), 39 | CodingStateMachine(ISO2022JPSMModel), 40 | CodingStateMachine(ISO2022KRSMModel) 41 | ] 42 | self.reset() 43 | 44 | def reset(self): 45 | CharSetProber.reset(self) 46 | for codingSM in self._mCodingSM: 47 | if not codingSM: continue 48 | codingSM.active = constants.True 49 | codingSM.reset() 50 | self._mActiveSM = len(self._mCodingSM) 51 | self._mDetectedCharset = None 52 | 53 | def get_charset_name(self): 54 | return self._mDetectedCharset 55 | 56 | def get_confidence(self): 57 | if self._mDetectedCharset: 58 | return 0.99 59 | else: 60 | return 0.00 61 | 62 | def feed(self, aBuf): 63 | for c in aBuf: 64 | for codingSM in self._mCodingSM: 65 | if not codingSM: continue 66 | if not codingSM.active: continue 67 | codingState = codingSM.next_state(c) 68 | if codingState == constants.eError: 69 | codingSM.active = constants.False 70 | self._mActiveSM -= 1 71 | if self._mActiveSM <= 0: 72 | self._mState = constants.eNotMe 73 | return self.get_state() 74 | elif codingState == constants.eItsMe: 75 | self._mState = constants.eFoundIt 76 | self._mDetectedCharset = codingSM.get_coding_state_machine() 77 | return self.get_state() 78 | 79 | return self.get_state() 80 | -------------------------------------------------------------------------------- /virtualenv.bundle/requests/packages/chardet/eucjpprober.py: -------------------------------------------------------------------------------- 1 | ######################## BEGIN LICENSE BLOCK ######################## 2 | # The Original Code is mozilla.org code. 3 | # 4 | # The Initial Developer of the Original Code is 5 | # Netscape Communications Corporation. 6 | # Portions created by the Initial Developer are Copyright (C) 1998 7 | # the Initial Developer. All Rights Reserved. 8 | # 9 | # Contributor(s): 10 | # Mark Pilgrim - port to Python 11 | # 12 | # This library is free software; you can redistribute it and/or 13 | # modify it under the terms of the GNU Lesser General Public 14 | # License as published by the Free Software Foundation; either 15 | # version 2.1 of the License, or (at your option) any later version. 16 | # 17 | # This library is distributed in the hope that it will be useful, 18 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 19 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 20 | # Lesser General Public License for more details. 21 | # 22 | # You should have received a copy of the GNU Lesser General Public 23 | # License along with this library; if not, write to the Free Software 24 | # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 25 | # 02110-1301 USA 26 | ######################### END LICENSE BLOCK ######################### 27 | 28 | import constants, sys 29 | from constants import eStart, eError, eItsMe 30 | from mbcharsetprober import MultiByteCharSetProber 31 | from codingstatemachine import CodingStateMachine 32 | from chardistribution import EUCJPDistributionAnalysis 33 | from jpcntx import EUCJPContextAnalysis 34 | from mbcssm import EUCJPSMModel 35 | 36 | class EUCJPProber(MultiByteCharSetProber): 37 | def __init__(self): 38 | MultiByteCharSetProber.__init__(self) 39 | self._mCodingSM = CodingStateMachine(EUCJPSMModel) 40 | self._mDistributionAnalyzer = EUCJPDistributionAnalysis() 41 | self._mContextAnalyzer = EUCJPContextAnalysis() 42 | self.reset() 43 | 44 | def reset(self): 45 | MultiByteCharSetProber.reset(self) 46 | self._mContextAnalyzer.reset() 47 | 48 | def get_charset_name(self): 49 | return "EUC-JP" 50 | 51 | def feed(self, aBuf): 52 | aLen = len(aBuf) 53 | for i in range(0, aLen): 54 | codingState = self._mCodingSM.next_state(aBuf[i]) 55 | if codingState == eError: 56 | if constants._debug: 57 | sys.stderr.write(self.get_charset_name() + ' prober hit error at byte ' + str(i) + '\n') 58 | self._mState = constants.eNotMe 59 | break 60 | elif codingState == eItsMe: 61 | self._mState = constants.eFoundIt 62 | break 63 | elif codingState == eStart: 64 | charLen = self._mCodingSM.get_current_charlen() 65 | if i == 0: 66 | self._mLastChar[1] = aBuf[0] 67 | self._mContextAnalyzer.feed(self._mLastChar, charLen) 68 | self._mDistributionAnalyzer.feed(self._mLastChar, charLen) 69 | else: 70 | self._mContextAnalyzer.feed(aBuf[i-1:i+1], charLen) 71 | self._mDistributionAnalyzer.feed(aBuf[i-1:i+1], charLen) 72 | 73 | self._mLastChar[0] = aBuf[aLen - 1] 74 | 75 | if self.get_state() == constants.eDetecting: 76 | if self._mContextAnalyzer.got_enough_data() and \ 77 | (self.get_confidence() > constants.SHORTCUT_THRESHOLD): 78 | self._mState = constants.eFoundIt 79 | 80 | return self.get_state() 81 | 82 | def get_confidence(self): 83 | contxtCf = self._mContextAnalyzer.get_confidence() 84 | distribCf = self._mDistributionAnalyzer.get_confidence() 85 | return max(contxtCf, distribCf) 86 | -------------------------------------------------------------------------------- /virtualenv.bundle/requests/packages/chardet/euckrprober.py: -------------------------------------------------------------------------------- 1 | ######################## BEGIN LICENSE BLOCK ######################## 2 | # The Original Code is mozilla.org code. 3 | # 4 | # The Initial Developer of the Original Code is 5 | # Netscape Communications Corporation. 6 | # Portions created by the Initial Developer are Copyright (C) 1998 7 | # the Initial Developer. All Rights Reserved. 8 | # 9 | # Contributor(s): 10 | # Mark Pilgrim - port to Python 11 | # 12 | # This library is free software; you can redistribute it and/or 13 | # modify it under the terms of the GNU Lesser General Public 14 | # License as published by the Free Software Foundation; either 15 | # version 2.1 of the License, or (at your option) any later version. 16 | # 17 | # This library is distributed in the hope that it will be useful, 18 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 19 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 20 | # Lesser General Public License for more details. 21 | # 22 | # You should have received a copy of the GNU Lesser General Public 23 | # License along with this library; if not, write to the Free Software 24 | # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 25 | # 02110-1301 USA 26 | ######################### END LICENSE BLOCK ######################### 27 | 28 | from mbcharsetprober import MultiByteCharSetProber 29 | from codingstatemachine import CodingStateMachine 30 | from chardistribution import EUCKRDistributionAnalysis 31 | from mbcssm import EUCKRSMModel 32 | 33 | class EUCKRProber(MultiByteCharSetProber): 34 | def __init__(self): 35 | MultiByteCharSetProber.__init__(self) 36 | self._mCodingSM = CodingStateMachine(EUCKRSMModel) 37 | self._mDistributionAnalyzer = EUCKRDistributionAnalysis() 38 | self.reset() 39 | 40 | def get_charset_name(self): 41 | return "EUC-KR" 42 | -------------------------------------------------------------------------------- /virtualenv.bundle/requests/packages/chardet/euctwprober.py: -------------------------------------------------------------------------------- 1 | ######################## BEGIN LICENSE BLOCK ######################## 2 | # The Original Code is mozilla.org code. 3 | # 4 | # The Initial Developer of the Original Code is 5 | # Netscape Communications Corporation. 6 | # Portions created by the Initial Developer are Copyright (C) 1998 7 | # the Initial Developer. All Rights Reserved. 8 | # 9 | # Contributor(s): 10 | # Mark Pilgrim - port to Python 11 | # 12 | # This library is free software; you can redistribute it and/or 13 | # modify it under the terms of the GNU Lesser General Public 14 | # License as published by the Free Software Foundation; either 15 | # version 2.1 of the License, or (at your option) any later version. 16 | # 17 | # This library is distributed in the hope that it will be useful, 18 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 19 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 20 | # Lesser General Public License for more details. 21 | # 22 | # You should have received a copy of the GNU Lesser General Public 23 | # License along with this library; if not, write to the Free Software 24 | # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 25 | # 02110-1301 USA 26 | ######################### END LICENSE BLOCK ######################### 27 | 28 | from mbcharsetprober import MultiByteCharSetProber 29 | from codingstatemachine import CodingStateMachine 30 | from chardistribution import EUCTWDistributionAnalysis 31 | from mbcssm import EUCTWSMModel 32 | 33 | class EUCTWProber(MultiByteCharSetProber): 34 | def __init__(self): 35 | MultiByteCharSetProber.__init__(self) 36 | self._mCodingSM = CodingStateMachine(EUCTWSMModel) 37 | self._mDistributionAnalyzer = EUCTWDistributionAnalysis() 38 | self.reset() 39 | 40 | def get_charset_name(self): 41 | return "EUC-TW" 42 | -------------------------------------------------------------------------------- /virtualenv.bundle/requests/packages/chardet/gb2312prober.py: -------------------------------------------------------------------------------- 1 | ######################## BEGIN LICENSE BLOCK ######################## 2 | # The Original Code is mozilla.org code. 3 | # 4 | # The Initial Developer of the Original Code is 5 | # Netscape Communications Corporation. 6 | # Portions created by the Initial Developer are Copyright (C) 1998 7 | # the Initial Developer. All Rights Reserved. 8 | # 9 | # Contributor(s): 10 | # Mark Pilgrim - port to Python 11 | # 12 | # This library is free software; you can redistribute it and/or 13 | # modify it under the terms of the GNU Lesser General Public 14 | # License as published by the Free Software Foundation; either 15 | # version 2.1 of the License, or (at your option) any later version. 16 | # 17 | # This library is distributed in the hope that it will be useful, 18 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 19 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 20 | # Lesser General Public License for more details. 21 | # 22 | # You should have received a copy of the GNU Lesser General Public 23 | # License along with this library; if not, write to the Free Software 24 | # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 25 | # 02110-1301 USA 26 | ######################### END LICENSE BLOCK ######################### 27 | 28 | from mbcharsetprober import MultiByteCharSetProber 29 | from codingstatemachine import CodingStateMachine 30 | from chardistribution import GB2312DistributionAnalysis 31 | from mbcssm import GB2312SMModel 32 | 33 | class GB2312Prober(MultiByteCharSetProber): 34 | def __init__(self): 35 | MultiByteCharSetProber.__init__(self) 36 | self._mCodingSM = CodingStateMachine(GB2312SMModel) 37 | self._mDistributionAnalyzer = GB2312DistributionAnalysis() 38 | self.reset() 39 | 40 | def get_charset_name(self): 41 | return "GB2312" 42 | -------------------------------------------------------------------------------- /virtualenv.bundle/requests/packages/chardet/mbcharsetprober.py: -------------------------------------------------------------------------------- 1 | ######################## BEGIN LICENSE BLOCK ######################## 2 | # The Original Code is Mozilla Universal charset detector code. 3 | # 4 | # The Initial Developer of the Original Code is 5 | # Netscape Communications Corporation. 6 | # Portions created by the Initial Developer are Copyright (C) 2001 7 | # the Initial Developer. All Rights Reserved. 8 | # 9 | # Contributor(s): 10 | # Mark Pilgrim - port to Python 11 | # Shy Shalom - original C code 12 | # Proofpoint, Inc. 13 | # 14 | # This library is free software; you can redistribute it and/or 15 | # modify it under the terms of the GNU Lesser General Public 16 | # License as published by the Free Software Foundation; either 17 | # version 2.1 of the License, or (at your option) any later version. 18 | # 19 | # This library is distributed in the hope that it will be useful, 20 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 21 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 22 | # Lesser General Public License for more details. 23 | # 24 | # You should have received a copy of the GNU Lesser General Public 25 | # License along with this library; if not, write to the Free Software 26 | # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 27 | # 02110-1301 USA 28 | ######################### END LICENSE BLOCK ######################### 29 | 30 | import constants, sys 31 | from constants import eStart, eError, eItsMe 32 | from charsetprober import CharSetProber 33 | 34 | class MultiByteCharSetProber(CharSetProber): 35 | def __init__(self): 36 | CharSetProber.__init__(self) 37 | self._mDistributionAnalyzer = None 38 | self._mCodingSM = None 39 | self._mLastChar = ['\x00', '\x00'] 40 | 41 | def reset(self): 42 | CharSetProber.reset(self) 43 | if self._mCodingSM: 44 | self._mCodingSM.reset() 45 | if self._mDistributionAnalyzer: 46 | self._mDistributionAnalyzer.reset() 47 | self._mLastChar = ['\x00', '\x00'] 48 | 49 | def get_charset_name(self): 50 | pass 51 | 52 | def feed(self, aBuf): 53 | aLen = len(aBuf) 54 | for i in range(0, aLen): 55 | codingState = self._mCodingSM.next_state(aBuf[i]) 56 | if codingState == eError: 57 | if constants._debug: 58 | sys.stderr.write(self.get_charset_name() + ' prober hit error at byte ' + str(i) + '\n') 59 | self._mState = constants.eNotMe 60 | break 61 | elif codingState == eItsMe: 62 | self._mState = constants.eFoundIt 63 | break 64 | elif codingState == eStart: 65 | charLen = self._mCodingSM.get_current_charlen() 66 | if i == 0: 67 | self._mLastChar[1] = aBuf[0] 68 | self._mDistributionAnalyzer.feed(self._mLastChar, charLen) 69 | else: 70 | self._mDistributionAnalyzer.feed(aBuf[i-1:i+1], charLen) 71 | 72 | self._mLastChar[0] = aBuf[aLen - 1] 73 | 74 | if self.get_state() == constants.eDetecting: 75 | if self._mDistributionAnalyzer.got_enough_data() and \ 76 | (self.get_confidence() > constants.SHORTCUT_THRESHOLD): 77 | self._mState = constants.eFoundIt 78 | 79 | return self.get_state() 80 | 81 | def get_confidence(self): 82 | return self._mDistributionAnalyzer.get_confidence() 83 | -------------------------------------------------------------------------------- /virtualenv.bundle/requests/packages/chardet/mbcsgroupprober.py: -------------------------------------------------------------------------------- 1 | ######################## BEGIN LICENSE BLOCK ######################## 2 | # The Original Code is Mozilla Universal charset detector code. 3 | # 4 | # The Initial Developer of the Original Code is 5 | # Netscape Communications Corporation. 6 | # Portions created by the Initial Developer are Copyright (C) 2001 7 | # the Initial Developer. All Rights Reserved. 8 | # 9 | # Contributor(s): 10 | # Mark Pilgrim - port to Python 11 | # Shy Shalom - original C code 12 | # Proofpoint, Inc. 13 | # 14 | # This library is free software; you can redistribute it and/or 15 | # modify it under the terms of the GNU Lesser General Public 16 | # License as published by the Free Software Foundation; either 17 | # version 2.1 of the License, or (at your option) any later version. 18 | # 19 | # This library is distributed in the hope that it will be useful, 20 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 21 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 22 | # Lesser General Public License for more details. 23 | # 24 | # You should have received a copy of the GNU Lesser General Public 25 | # License along with this library; if not, write to the Free Software 26 | # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 27 | # 02110-1301 USA 28 | ######################### END LICENSE BLOCK ######################### 29 | 30 | from charsetgroupprober import CharSetGroupProber 31 | from utf8prober import UTF8Prober 32 | from sjisprober import SJISProber 33 | from eucjpprober import EUCJPProber 34 | from gb2312prober import GB2312Prober 35 | from euckrprober import EUCKRProber 36 | from big5prober import Big5Prober 37 | from euctwprober import EUCTWProber 38 | 39 | class MBCSGroupProber(CharSetGroupProber): 40 | def __init__(self): 41 | CharSetGroupProber.__init__(self) 42 | self._mProbers = [ \ 43 | UTF8Prober(), 44 | SJISProber(), 45 | EUCJPProber(), 46 | GB2312Prober(), 47 | EUCKRProber(), 48 | Big5Prober(), 49 | EUCTWProber()] 50 | self.reset() 51 | -------------------------------------------------------------------------------- /virtualenv.bundle/requests/packages/chardet/sbcsgroupprober.py: -------------------------------------------------------------------------------- 1 | ######################## BEGIN LICENSE BLOCK ######################## 2 | # The Original Code is Mozilla Universal charset detector code. 3 | # 4 | # The Initial Developer of the Original Code is 5 | # Netscape Communications Corporation. 6 | # Portions created by the Initial Developer are Copyright (C) 2001 7 | # the Initial Developer. All Rights Reserved. 8 | # 9 | # Contributor(s): 10 | # Mark Pilgrim - port to Python 11 | # Shy Shalom - original C code 12 | # 13 | # This library is free software; you can redistribute it and/or 14 | # modify it under the terms of the GNU Lesser General Public 15 | # License as published by the Free Software Foundation; either 16 | # version 2.1 of the License, or (at your option) any later version. 17 | # 18 | # This library is distributed in the hope that it will be useful, 19 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 20 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 21 | # Lesser General Public License for more details. 22 | # 23 | # You should have received a copy of the GNU Lesser General Public 24 | # License along with this library; if not, write to the Free Software 25 | # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 26 | # 02110-1301 USA 27 | ######################### END LICENSE BLOCK ######################### 28 | 29 | import constants, sys 30 | from charsetgroupprober import CharSetGroupProber 31 | from sbcharsetprober import SingleByteCharSetProber 32 | from langcyrillicmodel import Win1251CyrillicModel, Koi8rModel, Latin5CyrillicModel, MacCyrillicModel, Ibm866Model, Ibm855Model 33 | from langgreekmodel import Latin7GreekModel, Win1253GreekModel 34 | from langbulgarianmodel import Latin5BulgarianModel, Win1251BulgarianModel 35 | from langhungarianmodel import Latin2HungarianModel, Win1250HungarianModel 36 | from langthaimodel import TIS620ThaiModel 37 | from langhebrewmodel import Win1255HebrewModel 38 | from hebrewprober import HebrewProber 39 | 40 | class SBCSGroupProber(CharSetGroupProber): 41 | def __init__(self): 42 | CharSetGroupProber.__init__(self) 43 | self._mProbers = [ \ 44 | SingleByteCharSetProber(Win1251CyrillicModel), 45 | SingleByteCharSetProber(Koi8rModel), 46 | SingleByteCharSetProber(Latin5CyrillicModel), 47 | SingleByteCharSetProber(MacCyrillicModel), 48 | SingleByteCharSetProber(Ibm866Model), 49 | SingleByteCharSetProber(Ibm855Model), 50 | SingleByteCharSetProber(Latin7GreekModel), 51 | SingleByteCharSetProber(Win1253GreekModel), 52 | SingleByteCharSetProber(Latin5BulgarianModel), 53 | SingleByteCharSetProber(Win1251BulgarianModel), 54 | SingleByteCharSetProber(Latin2HungarianModel), 55 | SingleByteCharSetProber(Win1250HungarianModel), 56 | SingleByteCharSetProber(TIS620ThaiModel), 57 | ] 58 | hebrewProber = HebrewProber() 59 | logicalHebrewProber = SingleByteCharSetProber(Win1255HebrewModel, constants.False, hebrewProber) 60 | visualHebrewProber = SingleByteCharSetProber(Win1255HebrewModel, constants.True, hebrewProber) 61 | hebrewProber.set_model_probers(logicalHebrewProber, visualHebrewProber) 62 | self._mProbers.extend([hebrewProber, logicalHebrewProber, visualHebrewProber]) 63 | 64 | self.reset() 65 | -------------------------------------------------------------------------------- /virtualenv.bundle/requests/packages/chardet/sjisprober.py: -------------------------------------------------------------------------------- 1 | ######################## BEGIN LICENSE BLOCK ######################## 2 | # The Original Code is mozilla.org code. 3 | # 4 | # The Initial Developer of the Original Code is 5 | # Netscape Communications Corporation. 6 | # Portions created by the Initial Developer are Copyright (C) 1998 7 | # the Initial Developer. All Rights Reserved. 8 | # 9 | # Contributor(s): 10 | # Mark Pilgrim - port to Python 11 | # 12 | # This library is free software; you can redistribute it and/or 13 | # modify it under the terms of the GNU Lesser General Public 14 | # License as published by the Free Software Foundation; either 15 | # version 2.1 of the License, or (at your option) any later version. 16 | # 17 | # This library is distributed in the hope that it will be useful, 18 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 19 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 20 | # Lesser General Public License for more details. 21 | # 22 | # You should have received a copy of the GNU Lesser General Public 23 | # License along with this library; if not, write to the Free Software 24 | # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 25 | # 02110-1301 USA 26 | ######################### END LICENSE BLOCK ######################### 27 | 28 | from mbcharsetprober import MultiByteCharSetProber 29 | from codingstatemachine import CodingStateMachine 30 | from chardistribution import SJISDistributionAnalysis 31 | from jpcntx import SJISContextAnalysis 32 | from mbcssm import SJISSMModel 33 | import constants, sys 34 | from constants import eStart, eError, eItsMe 35 | 36 | class SJISProber(MultiByteCharSetProber): 37 | def __init__(self): 38 | MultiByteCharSetProber.__init__(self) 39 | self._mCodingSM = CodingStateMachine(SJISSMModel) 40 | self._mDistributionAnalyzer = SJISDistributionAnalysis() 41 | self._mContextAnalyzer = SJISContextAnalysis() 42 | self.reset() 43 | 44 | def reset(self): 45 | MultiByteCharSetProber.reset(self) 46 | self._mContextAnalyzer.reset() 47 | 48 | def get_charset_name(self): 49 | return "SHIFT_JIS" 50 | 51 | def feed(self, aBuf): 52 | aLen = len(aBuf) 53 | for i in range(0, aLen): 54 | codingState = self._mCodingSM.next_state(aBuf[i]) 55 | if codingState == eError: 56 | if constants._debug: 57 | sys.stderr.write(self.get_charset_name() + ' prober hit error at byte ' + str(i) + '\n') 58 | self._mState = constants.eNotMe 59 | break 60 | elif codingState == eItsMe: 61 | self._mState = constants.eFoundIt 62 | break 63 | elif codingState == eStart: 64 | charLen = self._mCodingSM.get_current_charlen() 65 | if i == 0: 66 | self._mLastChar[1] = aBuf[0] 67 | self._mContextAnalyzer.feed(self._mLastChar[2 - charLen :], charLen) 68 | self._mDistributionAnalyzer.feed(self._mLastChar, charLen) 69 | else: 70 | self._mContextAnalyzer.feed(aBuf[i + 1 - charLen : i + 3 - charLen], charLen) 71 | self._mDistributionAnalyzer.feed(aBuf[i - 1 : i + 1], charLen) 72 | 73 | self._mLastChar[0] = aBuf[aLen - 1] 74 | 75 | if self.get_state() == constants.eDetecting: 76 | if self._mContextAnalyzer.got_enough_data() and \ 77 | (self.get_confidence() > constants.SHORTCUT_THRESHOLD): 78 | self._mState = constants.eFoundIt 79 | 80 | return self.get_state() 81 | 82 | def get_confidence(self): 83 | contxtCf = self._mContextAnalyzer.get_confidence() 84 | distribCf = self._mDistributionAnalyzer.get_confidence() 85 | return max(contxtCf, distribCf) 86 | -------------------------------------------------------------------------------- /virtualenv.bundle/requests/packages/chardet/utf8prober.py: -------------------------------------------------------------------------------- 1 | ######################## BEGIN LICENSE BLOCK ######################## 2 | # The Original Code is mozilla.org code. 3 | # 4 | # The Initial Developer of the Original Code is 5 | # Netscape Communications Corporation. 6 | # Portions created by the Initial Developer are Copyright (C) 1998 7 | # the Initial Developer. All Rights Reserved. 8 | # 9 | # Contributor(s): 10 | # Mark Pilgrim - port to Python 11 | # 12 | # This library is free software; you can redistribute it and/or 13 | # modify it under the terms of the GNU Lesser General Public 14 | # License as published by the Free Software Foundation; either 15 | # version 2.1 of the License, or (at your option) any later version. 16 | # 17 | # This library is distributed in the hope that it will be useful, 18 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 19 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 20 | # Lesser General Public License for more details. 21 | # 22 | # You should have received a copy of the GNU Lesser General Public 23 | # License along with this library; if not, write to the Free Software 24 | # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 25 | # 02110-1301 USA 26 | ######################### END LICENSE BLOCK ######################### 27 | 28 | import constants, sys 29 | from constants import eStart, eError, eItsMe 30 | from charsetprober import CharSetProber 31 | from codingstatemachine import CodingStateMachine 32 | from mbcssm import UTF8SMModel 33 | 34 | ONE_CHAR_PROB = 0.5 35 | 36 | class UTF8Prober(CharSetProber): 37 | def __init__(self): 38 | CharSetProber.__init__(self) 39 | self._mCodingSM = CodingStateMachine(UTF8SMModel) 40 | self.reset() 41 | 42 | def reset(self): 43 | CharSetProber.reset(self) 44 | self._mCodingSM.reset() 45 | self._mNumOfMBChar = 0 46 | 47 | def get_charset_name(self): 48 | return "utf-8" 49 | 50 | def feed(self, aBuf): 51 | for c in aBuf: 52 | codingState = self._mCodingSM.next_state(c) 53 | if codingState == eError: 54 | self._mState = constants.eNotMe 55 | break 56 | elif codingState == eItsMe: 57 | self._mState = constants.eFoundIt 58 | break 59 | elif codingState == eStart: 60 | if self._mCodingSM.get_current_charlen() >= 2: 61 | self._mNumOfMBChar += 1 62 | 63 | if self.get_state() == constants.eDetecting: 64 | if self.get_confidence() > constants.SHORTCUT_THRESHOLD: 65 | self._mState = constants.eFoundIt 66 | 67 | return self.get_state() 68 | 69 | def get_confidence(self): 70 | unlike = 0.99 71 | if self._mNumOfMBChar < 6: 72 | for i in range(0, self._mNumOfMBChar): 73 | unlike = unlike * ONE_CHAR_PROB 74 | return 1.0 - unlike 75 | else: 76 | return unlike 77 | -------------------------------------------------------------------------------- /virtualenv.bundle/requests/packages/chardet2/__init__.py: -------------------------------------------------------------------------------- 1 | ######################## BEGIN LICENSE BLOCK ######################## 2 | # This library is free software; you can redistribute it and/or 3 | # modify it under the terms of the GNU Lesser General Public 4 | # License as published by the Free Software Foundation; either 5 | # version 2.1 of the License, or (at your option) any later version. 6 | # 7 | # This library is distributed in the hope that it will be useful, 8 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 9 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 10 | # Lesser General Public License for more details. 11 | # 12 | # You should have received a copy of the GNU Lesser General Public 13 | # License along with this library; if not, write to the Free Software 14 | # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 15 | # 02110-1301 USA 16 | ######################### END LICENSE BLOCK ######################### 17 | 18 | __version__ = "2.0.1" 19 | 20 | def detect(aBuf): 21 | from . import universaldetector 22 | u = universaldetector.UniversalDetector() 23 | u.reset() 24 | u.feed(aBuf) 25 | u.close() 26 | return u.result 27 | -------------------------------------------------------------------------------- /virtualenv.bundle/requests/packages/chardet2/big5prober.py: -------------------------------------------------------------------------------- 1 | ######################## BEGIN LICENSE BLOCK ######################## 2 | # The Original Code is Mozilla Communicator client code. 3 | # 4 | # The Initial Developer of the Original Code is 5 | # Netscape Communications Corporation. 6 | # Portions created by the Initial Developer are Copyright (C) 1998 7 | # the Initial Developer. All Rights Reserved. 8 | # 9 | # Contributor(s): 10 | # Mark Pilgrim - port to Python 11 | # 12 | # This library is free software; you can redistribute it and/or 13 | # modify it under the terms of the GNU Lesser General Public 14 | # License as published by the Free Software Foundation; either 15 | # version 2.1 of the License, or (at your option) any later version. 16 | # 17 | # This library is distributed in the hope that it will be useful, 18 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 19 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 20 | # Lesser General Public License for more details. 21 | # 22 | # You should have received a copy of the GNU Lesser General Public 23 | # License along with this library; if not, write to the Free Software 24 | # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 25 | # 02110-1301 USA 26 | ######################### END LICENSE BLOCK ######################### 27 | 28 | from .mbcharsetprober import MultiByteCharSetProber 29 | from .codingstatemachine import CodingStateMachine 30 | from .chardistribution import Big5DistributionAnalysis 31 | from .mbcssm import Big5SMModel 32 | 33 | class Big5Prober(MultiByteCharSetProber): 34 | def __init__(self): 35 | MultiByteCharSetProber.__init__(self) 36 | self._mCodingSM = CodingStateMachine(Big5SMModel) 37 | self._mDistributionAnalyzer = Big5DistributionAnalysis() 38 | self.reset() 39 | 40 | def get_charset_name(self): 41 | return "Big5" 42 | -------------------------------------------------------------------------------- /virtualenv.bundle/requests/packages/chardet2/charsetgroupprober.py: -------------------------------------------------------------------------------- 1 | ######################## BEGIN LICENSE BLOCK ######################## 2 | # The Original Code is Mozilla Communicator client code. 3 | # 4 | # The Initial Developer of the Original Code is 5 | # Netscape Communications Corporation. 6 | # Portions created by the Initial Developer are Copyright (C) 1998 7 | # the Initial Developer. All Rights Reserved. 8 | # 9 | # Contributor(s): 10 | # Mark Pilgrim - port to Python 11 | # 12 | # This library is free software; you can redistribute it and/or 13 | # modify it under the terms of the GNU Lesser General Public 14 | # License as published by the Free Software Foundation; either 15 | # version 2.1 of the License, or (at your option) any later version. 16 | # 17 | # This library is distributed in the hope that it will be useful, 18 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 19 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 20 | # Lesser General Public License for more details. 21 | # 22 | # You should have received a copy of the GNU Lesser General Public 23 | # License along with this library; if not, write to the Free Software 24 | # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 25 | # 02110-1301 USA 26 | ######################### END LICENSE BLOCK ######################### 27 | 28 | from . import constants 29 | import sys 30 | from .charsetprober import CharSetProber 31 | 32 | class CharSetGroupProber(CharSetProber): 33 | def __init__(self): 34 | CharSetProber.__init__(self) 35 | self._mActiveNum = 0 36 | self._mProbers = [] 37 | self._mBestGuessProber = None 38 | 39 | def reset(self): 40 | CharSetProber.reset(self) 41 | self._mActiveNum = 0 42 | for prober in self._mProbers: 43 | if prober: 44 | prober.reset() 45 | prober.active = True 46 | self._mActiveNum += 1 47 | self._mBestGuessProber = None 48 | 49 | def get_charset_name(self): 50 | if not self._mBestGuessProber: 51 | self.get_confidence() 52 | if not self._mBestGuessProber: return None 53 | # self._mBestGuessProber = self._mProbers[0] 54 | return self._mBestGuessProber.get_charset_name() 55 | 56 | def feed(self, aBuf): 57 | for prober in self._mProbers: 58 | if not prober: continue 59 | if not prober.active: continue 60 | st = prober.feed(aBuf) 61 | if not st: continue 62 | if st == constants.eFoundIt: 63 | self._mBestGuessProber = prober 64 | return self.get_state() 65 | elif st == constants.eNotMe: 66 | prober.active = False 67 | self._mActiveNum -= 1 68 | if self._mActiveNum <= 0: 69 | self._mState = constants.eNotMe 70 | return self.get_state() 71 | return self.get_state() 72 | 73 | def get_confidence(self): 74 | st = self.get_state() 75 | if st == constants.eFoundIt: 76 | return 0.99 77 | elif st == constants.eNotMe: 78 | return 0.01 79 | bestConf = 0.0 80 | self._mBestGuessProber = None 81 | for prober in self._mProbers: 82 | if not prober: continue 83 | if not prober.active: 84 | if constants._debug: 85 | sys.stderr.write(prober.get_charset_name() + ' not active\n') 86 | continue 87 | cf = prober.get_confidence() 88 | if constants._debug: 89 | sys.stderr.write('%s confidence = %s\n' % (prober.get_charset_name(), cf)) 90 | if bestConf < cf: 91 | bestConf = cf 92 | self._mBestGuessProber = prober 93 | if not self._mBestGuessProber: return 0.0 94 | return bestConf 95 | # else: 96 | # self._mBestGuessProber = self._mProbers[0] 97 | # return self._mBestGuessProber.get_confidence() 98 | -------------------------------------------------------------------------------- /virtualenv.bundle/requests/packages/chardet2/charsetprober.py: -------------------------------------------------------------------------------- 1 | ######################## BEGIN LICENSE BLOCK ######################## 2 | # The Original Code is Mozilla Universal charset detector code. 3 | # 4 | # The Initial Developer of the Original Code is 5 | # Netscape Communications Corporation. 6 | # Portions created by the Initial Developer are Copyright (C) 2001 7 | # the Initial Developer. All Rights Reserved. 8 | # 9 | # Contributor(s): 10 | # Mark Pilgrim - port to Python 11 | # Shy Shalom - original C code 12 | # 13 | # This library is free software; you can redistribute it and/or 14 | # modify it under the terms of the GNU Lesser General Public 15 | # License as published by the Free Software Foundation; either 16 | # version 2.1 of the License, or (at your option) any later version. 17 | # 18 | # This library is distributed in the hope that it will be useful, 19 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 20 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 21 | # Lesser General Public License for more details. 22 | # 23 | # You should have received a copy of the GNU Lesser General Public 24 | # License along with this library; if not, write to the Free Software 25 | # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 26 | # 02110-1301 USA 27 | ######################### END LICENSE BLOCK ######################### 28 | 29 | from . import constants 30 | import re 31 | 32 | class CharSetProber: 33 | def __init__(self): 34 | pass 35 | 36 | def reset(self): 37 | self._mState = constants.eDetecting 38 | 39 | def get_charset_name(self): 40 | return None 41 | 42 | def feed(self, aBuf): 43 | pass 44 | 45 | def get_state(self): 46 | return self._mState 47 | 48 | def get_confidence(self): 49 | return 0.0 50 | 51 | def filter_high_bit_only(self, aBuf): 52 | aBuf = re.sub(b'([\x00-\x7F])+', b' ', aBuf) 53 | return aBuf 54 | 55 | def filter_without_english_letters(self, aBuf): 56 | aBuf = re.sub(b'([A-Za-z])+', b' ', aBuf) 57 | return aBuf 58 | 59 | def filter_with_english_letters(self, aBuf): 60 | # TODO 61 | return aBuf 62 | -------------------------------------------------------------------------------- /virtualenv.bundle/requests/packages/chardet2/codingstatemachine.py: -------------------------------------------------------------------------------- 1 | ######################## BEGIN LICENSE BLOCK ######################## 2 | # The Original Code is mozilla.org code. 3 | # 4 | # The Initial Developer of the Original Code is 5 | # Netscape Communications Corporation. 6 | # Portions created by the Initial Developer are Copyright (C) 1998 7 | # the Initial Developer. All Rights Reserved. 8 | # 9 | # Contributor(s): 10 | # Mark Pilgrim - port to Python 11 | # 12 | # This library is free software; you can redistribute it and/or 13 | # modify it under the terms of the GNU Lesser General Public 14 | # License as published by the Free Software Foundation; either 15 | # version 2.1 of the License, or (at your option) any later version. 16 | # 17 | # This library is distributed in the hope that it will be useful, 18 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 19 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 20 | # Lesser General Public License for more details. 21 | # 22 | # You should have received a copy of the GNU Lesser General Public 23 | # License along with this library; if not, write to the Free Software 24 | # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 25 | # 02110-1301 USA 26 | ######################### END LICENSE BLOCK ######################### 27 | 28 | from .constants import eStart, eError, eItsMe 29 | 30 | class CodingStateMachine: 31 | def __init__(self, sm): 32 | self._mModel = sm 33 | self._mCurrentBytePos = 0 34 | self._mCurrentCharLen = 0 35 | self.reset() 36 | 37 | def reset(self): 38 | self._mCurrentState = eStart 39 | 40 | def next_state(self, c): 41 | # for each byte we get its class 42 | # if it is first byte, we also get byte length 43 | # PY3K: aBuf is a byte stream, so c is an int, not a byte 44 | byteCls = self._mModel['classTable'][c] 45 | if self._mCurrentState == eStart: 46 | self._mCurrentBytePos = 0 47 | self._mCurrentCharLen = self._mModel['charLenTable'][byteCls] 48 | # from byte's class and stateTable, we get its next state 49 | self._mCurrentState = self._mModel['stateTable'][self._mCurrentState * self._mModel['classFactor'] + byteCls] 50 | self._mCurrentBytePos += 1 51 | return self._mCurrentState 52 | 53 | def get_current_charlen(self): 54 | return self._mCurrentCharLen 55 | 56 | def get_coding_state_machine(self): 57 | return self._mModel['name'] 58 | -------------------------------------------------------------------------------- /virtualenv.bundle/requests/packages/chardet2/constants.py: -------------------------------------------------------------------------------- 1 | ######################## BEGIN LICENSE BLOCK ######################## 2 | # The Original Code is Mozilla Universal charset detector code. 3 | # 4 | # The Initial Developer of the Original Code is 5 | # Netscape Communications Corporation. 6 | # Portions created by the Initial Developer are Copyright (C) 2001 7 | # the Initial Developer. All Rights Reserved. 8 | # 9 | # Contributor(s): 10 | # Mark Pilgrim - port to Python 11 | # Shy Shalom - original C code 12 | # 13 | # This library is free software; you can redistribute it and/or 14 | # modify it under the terms of the GNU Lesser General Public 15 | # License as published by the Free Software Foundation; either 16 | # version 2.1 of the License, or (at your option) any later version. 17 | # 18 | # This library is distributed in the hope that it will be useful, 19 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 20 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 21 | # Lesser General Public License for more details. 22 | # 23 | # You should have received a copy of the GNU Lesser General Public 24 | # License along with this library; if not, write to the Free Software 25 | # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 26 | # 02110-1301 USA 27 | ######################### END LICENSE BLOCK ######################### 28 | 29 | _debug = 0 30 | 31 | eDetecting = 0 32 | eFoundIt = 1 33 | eNotMe = 2 34 | 35 | eStart = 0 36 | eError = 1 37 | eItsMe = 2 38 | 39 | SHORTCUT_THRESHOLD = 0.95 40 | -------------------------------------------------------------------------------- /virtualenv.bundle/requests/packages/chardet2/escprober.py: -------------------------------------------------------------------------------- 1 | ######################## BEGIN LICENSE BLOCK ######################## 2 | # The Original Code is mozilla.org code. 3 | # 4 | # The Initial Developer of the Original Code is 5 | # Netscape Communications Corporation. 6 | # Portions created by the Initial Developer are Copyright (C) 1998 7 | # the Initial Developer. All Rights Reserved. 8 | # 9 | # Contributor(s): 10 | # Mark Pilgrim - port to Python 11 | # 12 | # This library is free software; you can redistribute it and/or 13 | # modify it under the terms of the GNU Lesser General Public 14 | # License as published by the Free Software Foundation; either 15 | # version 2.1 of the License, or (at your option) any later version. 16 | # 17 | # This library is distributed in the hope that it will be useful, 18 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 19 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 20 | # Lesser General Public License for more details. 21 | # 22 | # You should have received a copy of the GNU Lesser General Public 23 | # License along with this library; if not, write to the Free Software 24 | # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 25 | # 02110-1301 USA 26 | ######################### END LICENSE BLOCK ######################### 27 | 28 | from . import constants 29 | import sys 30 | from .escsm import HZSMModel, ISO2022CNSMModel, ISO2022JPSMModel, ISO2022KRSMModel 31 | from .charsetprober import CharSetProber 32 | from .codingstatemachine import CodingStateMachine 33 | 34 | class EscCharSetProber(CharSetProber): 35 | def __init__(self): 36 | CharSetProber.__init__(self) 37 | self._mCodingSM = [ \ 38 | CodingStateMachine(HZSMModel), 39 | CodingStateMachine(ISO2022CNSMModel), 40 | CodingStateMachine(ISO2022JPSMModel), 41 | CodingStateMachine(ISO2022KRSMModel) 42 | ] 43 | self.reset() 44 | 45 | def reset(self): 46 | CharSetProber.reset(self) 47 | for codingSM in self._mCodingSM: 48 | if not codingSM: continue 49 | codingSM.active = True 50 | codingSM.reset() 51 | self._mActiveSM = len(self._mCodingSM) 52 | self._mDetectedCharset = None 53 | 54 | def get_charset_name(self): 55 | return self._mDetectedCharset 56 | 57 | def get_confidence(self): 58 | if self._mDetectedCharset: 59 | return 0.99 60 | else: 61 | return 0.00 62 | 63 | def feed(self, aBuf): 64 | for c in aBuf: 65 | # PY3K: aBuf is a byte array, so c is an int, not a byte 66 | for codingSM in self._mCodingSM: 67 | if not codingSM: continue 68 | if not codingSM.active: continue 69 | codingState = codingSM.next_state(c) 70 | if codingState == constants.eError: 71 | codingSM.active = False 72 | self._mActiveSM -= 1 73 | if self._mActiveSM <= 0: 74 | self._mState = constants.eNotMe 75 | return self.get_state() 76 | elif codingState == constants.eItsMe: 77 | self._mState = constants.eFoundIt 78 | self._mDetectedCharset = codingSM.get_coding_state_machine() 79 | return self.get_state() 80 | 81 | return self.get_state() 82 | -------------------------------------------------------------------------------- /virtualenv.bundle/requests/packages/chardet2/eucjpprober.py: -------------------------------------------------------------------------------- 1 | ######################## BEGIN LICENSE BLOCK ######################## 2 | # The Original Code is mozilla.org code. 3 | # 4 | # The Initial Developer of the Original Code is 5 | # Netscape Communications Corporation. 6 | # Portions created by the Initial Developer are Copyright (C) 1998 7 | # the Initial Developer. All Rights Reserved. 8 | # 9 | # Contributor(s): 10 | # Mark Pilgrim - port to Python 11 | # 12 | # This library is free software; you can redistribute it and/or 13 | # modify it under the terms of the GNU Lesser General Public 14 | # License as published by the Free Software Foundation; either 15 | # version 2.1 of the License, or (at your option) any later version. 16 | # 17 | # This library is distributed in the hope that it will be useful, 18 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 19 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 20 | # Lesser General Public License for more details. 21 | # 22 | # You should have received a copy of the GNU Lesser General Public 23 | # License along with this library; if not, write to the Free Software 24 | # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 25 | # 02110-1301 USA 26 | ######################### END LICENSE BLOCK ######################### 27 | 28 | from . import constants 29 | import sys 30 | from .constants import eStart, eError, eItsMe 31 | from .mbcharsetprober import MultiByteCharSetProber 32 | from .codingstatemachine import CodingStateMachine 33 | from .chardistribution import EUCJPDistributionAnalysis 34 | from .jpcntx import EUCJPContextAnalysis 35 | from .mbcssm import EUCJPSMModel 36 | 37 | class EUCJPProber(MultiByteCharSetProber): 38 | def __init__(self): 39 | MultiByteCharSetProber.__init__(self) 40 | self._mCodingSM = CodingStateMachine(EUCJPSMModel) 41 | self._mDistributionAnalyzer = EUCJPDistributionAnalysis() 42 | self._mContextAnalyzer = EUCJPContextAnalysis() 43 | self.reset() 44 | 45 | def reset(self): 46 | MultiByteCharSetProber.reset(self) 47 | self._mContextAnalyzer.reset() 48 | 49 | def get_charset_name(self): 50 | return "EUC-JP" 51 | 52 | def feed(self, aBuf): 53 | aLen = len(aBuf) 54 | for i in range(0, aLen): 55 | # PY3K: aBuf is a byte array, so aBuf[i] is an int, not a byte 56 | codingState = self._mCodingSM.next_state(aBuf[i]) 57 | if codingState == eError: 58 | if constants._debug: 59 | sys.stderr.write(self.get_charset_name() + ' prober hit error at byte ' + str(i) + '\n') 60 | self._mState = constants.eNotMe 61 | break 62 | elif codingState == eItsMe: 63 | self._mState = constants.eFoundIt 64 | break 65 | elif codingState == eStart: 66 | charLen = self._mCodingSM.get_current_charlen() 67 | if i == 0: 68 | self._mLastChar[1] = aBuf[0] 69 | self._mContextAnalyzer.feed(self._mLastChar, charLen) 70 | self._mDistributionAnalyzer.feed(self._mLastChar, charLen) 71 | else: 72 | self._mContextAnalyzer.feed(aBuf[i-1:i+1], charLen) 73 | self._mDistributionAnalyzer.feed(aBuf[i-1:i+1], charLen) 74 | 75 | self._mLastChar[0] = aBuf[aLen - 1] 76 | 77 | if self.get_state() == constants.eDetecting: 78 | if self._mContextAnalyzer.got_enough_data() and \ 79 | (self.get_confidence() > constants.SHORTCUT_THRESHOLD): 80 | self._mState = constants.eFoundIt 81 | 82 | return self.get_state() 83 | 84 | def get_confidence(self): 85 | contxtCf = self._mContextAnalyzer.get_confidence() 86 | distribCf = self._mDistributionAnalyzer.get_confidence() 87 | return max(contxtCf, distribCf) 88 | -------------------------------------------------------------------------------- /virtualenv.bundle/requests/packages/chardet2/euckrprober.py: -------------------------------------------------------------------------------- 1 | ######################## BEGIN LICENSE BLOCK ######################## 2 | # The Original Code is mozilla.org code. 3 | # 4 | # The Initial Developer of the Original Code is 5 | # Netscape Communications Corporation. 6 | # Portions created by the Initial Developer are Copyright (C) 1998 7 | # the Initial Developer. All Rights Reserved. 8 | # 9 | # Contributor(s): 10 | # Mark Pilgrim - port to Python 11 | # 12 | # This library is free software; you can redistribute it and/or 13 | # modify it under the terms of the GNU Lesser General Public 14 | # License as published by the Free Software Foundation; either 15 | # version 2.1 of the License, or (at your option) any later version. 16 | # 17 | # This library is distributed in the hope that it will be useful, 18 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 19 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 20 | # Lesser General Public License for more details. 21 | # 22 | # You should have received a copy of the GNU Lesser General Public 23 | # License along with this library; if not, write to the Free Software 24 | # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 25 | # 02110-1301 USA 26 | ######################### END LICENSE BLOCK ######################### 27 | 28 | from .mbcharsetprober import MultiByteCharSetProber 29 | from .codingstatemachine import CodingStateMachine 30 | from .chardistribution import EUCKRDistributionAnalysis 31 | from .mbcssm import EUCKRSMModel 32 | 33 | class EUCKRProber(MultiByteCharSetProber): 34 | def __init__(self): 35 | MultiByteCharSetProber.__init__(self) 36 | self._mCodingSM = CodingStateMachine(EUCKRSMModel) 37 | self._mDistributionAnalyzer = EUCKRDistributionAnalysis() 38 | self.reset() 39 | 40 | def get_charset_name(self): 41 | return "EUC-KR" 42 | -------------------------------------------------------------------------------- /virtualenv.bundle/requests/packages/chardet2/euctwprober.py: -------------------------------------------------------------------------------- 1 | ######################## BEGIN LICENSE BLOCK ######################## 2 | # The Original Code is mozilla.org code. 3 | # 4 | # The Initial Developer of the Original Code is 5 | # Netscape Communications Corporation. 6 | # Portions created by the Initial Developer are Copyright (C) 1998 7 | # the Initial Developer. All Rights Reserved. 8 | # 9 | # Contributor(s): 10 | # Mark Pilgrim - port to Python 11 | # 12 | # This library is free software; you can redistribute it and/or 13 | # modify it under the terms of the GNU Lesser General Public 14 | # License as published by the Free Software Foundation; either 15 | # version 2.1 of the License, or (at your option) any later version. 16 | # 17 | # This library is distributed in the hope that it will be useful, 18 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 19 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 20 | # Lesser General Public License for more details. 21 | # 22 | # You should have received a copy of the GNU Lesser General Public 23 | # License along with this library; if not, write to the Free Software 24 | # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 25 | # 02110-1301 USA 26 | ######################### END LICENSE BLOCK ######################### 27 | 28 | from .mbcharsetprober import MultiByteCharSetProber 29 | from .codingstatemachine import CodingStateMachine 30 | from .chardistribution import EUCTWDistributionAnalysis 31 | from .mbcssm import EUCTWSMModel 32 | 33 | class EUCTWProber(MultiByteCharSetProber): 34 | def __init__(self): 35 | MultiByteCharSetProber.__init__(self) 36 | self._mCodingSM = CodingStateMachine(EUCTWSMModel) 37 | self._mDistributionAnalyzer = EUCTWDistributionAnalysis() 38 | self.reset() 39 | 40 | def get_charset_name(self): 41 | return "EUC-TW" 42 | -------------------------------------------------------------------------------- /virtualenv.bundle/requests/packages/chardet2/gb2312prober.py: -------------------------------------------------------------------------------- 1 | ######################## BEGIN LICENSE BLOCK ######################## 2 | # The Original Code is mozilla.org code. 3 | # 4 | # The Initial Developer of the Original Code is 5 | # Netscape Communications Corporation. 6 | # Portions created by the Initial Developer are Copyright (C) 1998 7 | # the Initial Developer. All Rights Reserved. 8 | # 9 | # Contributor(s): 10 | # Mark Pilgrim - port to Python 11 | # 12 | # This library is free software; you can redistribute it and/or 13 | # modify it under the terms of the GNU Lesser General Public 14 | # License as published by the Free Software Foundation; either 15 | # version 2.1 of the License, or (at your option) any later version. 16 | # 17 | # This library is distributed in the hope that it will be useful, 18 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 19 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 20 | # Lesser General Public License for more details. 21 | # 22 | # You should have received a copy of the GNU Lesser General Public 23 | # License along with this library; if not, write to the Free Software 24 | # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 25 | # 02110-1301 USA 26 | ######################### END LICENSE BLOCK ######################### 27 | 28 | from .mbcharsetprober import MultiByteCharSetProber 29 | from .codingstatemachine import CodingStateMachine 30 | from .chardistribution import GB2312DistributionAnalysis 31 | from .mbcssm import GB2312SMModel 32 | 33 | class GB2312Prober(MultiByteCharSetProber): 34 | def __init__(self): 35 | MultiByteCharSetProber.__init__(self) 36 | self._mCodingSM = CodingStateMachine(GB2312SMModel) 37 | self._mDistributionAnalyzer = GB2312DistributionAnalysis() 38 | self.reset() 39 | 40 | def get_charset_name(self): 41 | return "GB2312" 42 | -------------------------------------------------------------------------------- /virtualenv.bundle/requests/packages/chardet2/mbcharsetprober.py: -------------------------------------------------------------------------------- 1 | ######################## BEGIN LICENSE BLOCK ######################## 2 | # The Original Code is Mozilla Universal charset detector code. 3 | # 4 | # The Initial Developer of the Original Code is 5 | # Netscape Communications Corporation. 6 | # Portions created by the Initial Developer are Copyright (C) 2001 7 | # the Initial Developer. All Rights Reserved. 8 | # 9 | # Contributor(s): 10 | # Mark Pilgrim - port to Python 11 | # Shy Shalom - original C code 12 | # Proofpoint, Inc. 13 | # 14 | # This library is free software; you can redistribute it and/or 15 | # modify it under the terms of the GNU Lesser General Public 16 | # License as published by the Free Software Foundation; either 17 | # version 2.1 of the License, or (at your option) any later version. 18 | # 19 | # This library is distributed in the hope that it will be useful, 20 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 21 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 22 | # Lesser General Public License for more details. 23 | # 24 | # You should have received a copy of the GNU Lesser General Public 25 | # License along with this library; if not, write to the Free Software 26 | # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 27 | # 02110-1301 USA 28 | ######################### END LICENSE BLOCK ######################### 29 | 30 | from . import constants 31 | import sys 32 | from .constants import eStart, eError, eItsMe 33 | from .charsetprober import CharSetProber 34 | 35 | class MultiByteCharSetProber(CharSetProber): 36 | def __init__(self): 37 | CharSetProber.__init__(self) 38 | self._mDistributionAnalyzer = None 39 | self._mCodingSM = None 40 | self._mLastChar = [0, 0] 41 | 42 | def reset(self): 43 | CharSetProber.reset(self) 44 | if self._mCodingSM: 45 | self._mCodingSM.reset() 46 | if self._mDistributionAnalyzer: 47 | self._mDistributionAnalyzer.reset() 48 | self._mLastChar = [0, 0] 49 | 50 | def get_charset_name(self): 51 | pass 52 | 53 | def feed(self, aBuf): 54 | aLen = len(aBuf) 55 | for i in range(0, aLen): 56 | codingState = self._mCodingSM.next_state(aBuf[i]) 57 | if codingState == eError: 58 | if constants._debug: 59 | sys.stderr.write(self.get_charset_name() + ' prober hit error at byte ' + str(i) + '\n') 60 | self._mState = constants.eNotMe 61 | break 62 | elif codingState == eItsMe: 63 | self._mState = constants.eFoundIt 64 | break 65 | elif codingState == eStart: 66 | charLen = self._mCodingSM.get_current_charlen() 67 | if i == 0: 68 | self._mLastChar[1] = aBuf[0] 69 | self._mDistributionAnalyzer.feed(self._mLastChar, charLen) 70 | else: 71 | self._mDistributionAnalyzer.feed(aBuf[i-1:i+1], charLen) 72 | 73 | self._mLastChar[0] = aBuf[aLen - 1] 74 | 75 | if self.get_state() == constants.eDetecting: 76 | if self._mDistributionAnalyzer.got_enough_data() and \ 77 | (self.get_confidence() > constants.SHORTCUT_THRESHOLD): 78 | self._mState = constants.eFoundIt 79 | 80 | return self.get_state() 81 | 82 | def get_confidence(self): 83 | return self._mDistributionAnalyzer.get_confidence() 84 | -------------------------------------------------------------------------------- /virtualenv.bundle/requests/packages/chardet2/mbcsgroupprober.py: -------------------------------------------------------------------------------- 1 | ######################## BEGIN LICENSE BLOCK ######################## 2 | # The Original Code is Mozilla Universal charset detector code. 3 | # 4 | # The Initial Developer of the Original Code is 5 | # Netscape Communications Corporation. 6 | # Portions created by the Initial Developer are Copyright (C) 2001 7 | # the Initial Developer. All Rights Reserved. 8 | # 9 | # Contributor(s): 10 | # Mark Pilgrim - port to Python 11 | # Shy Shalom - original C code 12 | # Proofpoint, Inc. 13 | # 14 | # This library is free software; you can redistribute it and/or 15 | # modify it under the terms of the GNU Lesser General Public 16 | # License as published by the Free Software Foundation; either 17 | # version 2.1 of the License, or (at your option) any later version. 18 | # 19 | # This library is distributed in the hope that it will be useful, 20 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 21 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 22 | # Lesser General Public License for more details. 23 | # 24 | # You should have received a copy of the GNU Lesser General Public 25 | # License along with this library; if not, write to the Free Software 26 | # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 27 | # 02110-1301 USA 28 | ######################### END LICENSE BLOCK ######################### 29 | 30 | from .charsetgroupprober import CharSetGroupProber 31 | from .utf8prober import UTF8Prober 32 | from .sjisprober import SJISProber 33 | from .eucjpprober import EUCJPProber 34 | from .gb2312prober import GB2312Prober 35 | from .euckrprober import EUCKRProber 36 | from .big5prober import Big5Prober 37 | from .euctwprober import EUCTWProber 38 | 39 | class MBCSGroupProber(CharSetGroupProber): 40 | def __init__(self): 41 | CharSetGroupProber.__init__(self) 42 | self._mProbers = [ \ 43 | UTF8Prober(), 44 | SJISProber(), 45 | EUCJPProber(), 46 | GB2312Prober(), 47 | EUCKRProber(), 48 | Big5Prober(), 49 | EUCTWProber()] 50 | self.reset() 51 | -------------------------------------------------------------------------------- /virtualenv.bundle/requests/packages/chardet2/sbcsgroupprober.py: -------------------------------------------------------------------------------- 1 | ######################## BEGIN LICENSE BLOCK ######################## 2 | # The Original Code is Mozilla Universal charset detector code. 3 | # 4 | # The Initial Developer of the Original Code is 5 | # Netscape Communications Corporation. 6 | # Portions created by the Initial Developer are Copyright (C) 2001 7 | # the Initial Developer. All Rights Reserved. 8 | # 9 | # Contributor(s): 10 | # Mark Pilgrim - port to Python 11 | # Shy Shalom - original C code 12 | # 13 | # This library is free software; you can redistribute it and/or 14 | # modify it under the terms of the GNU Lesser General Public 15 | # License as published by the Free Software Foundation; either 16 | # version 2.1 of the License, or (at your option) any later version. 17 | # 18 | # This library is distributed in the hope that it will be useful, 19 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 20 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 21 | # Lesser General Public License for more details. 22 | # 23 | # You should have received a copy of the GNU Lesser General Public 24 | # License along with this library; if not, write to the Free Software 25 | # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 26 | # 02110-1301 USA 27 | ######################### END LICENSE BLOCK ######################### 28 | 29 | from . import constants 30 | import sys 31 | from .charsetgroupprober import CharSetGroupProber 32 | from .sbcharsetprober import SingleByteCharSetProber 33 | from .langcyrillicmodel import Win1251CyrillicModel, Koi8rModel, Latin5CyrillicModel, MacCyrillicModel, Ibm866Model, Ibm855Model 34 | from .langgreekmodel import Latin7GreekModel, Win1253GreekModel 35 | from .langbulgarianmodel import Latin5BulgarianModel, Win1251BulgarianModel 36 | from .langhungarianmodel import Latin2HungarianModel, Win1250HungarianModel 37 | from .langthaimodel import TIS620ThaiModel 38 | from .langhebrewmodel import Win1255HebrewModel 39 | from .hebrewprober import HebrewProber 40 | 41 | class SBCSGroupProber(CharSetGroupProber): 42 | def __init__(self): 43 | CharSetGroupProber.__init__(self) 44 | self._mProbers = [ \ 45 | SingleByteCharSetProber(Win1251CyrillicModel), 46 | SingleByteCharSetProber(Koi8rModel), 47 | SingleByteCharSetProber(Latin5CyrillicModel), 48 | SingleByteCharSetProber(MacCyrillicModel), 49 | SingleByteCharSetProber(Ibm866Model), 50 | SingleByteCharSetProber(Ibm855Model), 51 | SingleByteCharSetProber(Latin7GreekModel), 52 | SingleByteCharSetProber(Win1253GreekModel), 53 | SingleByteCharSetProber(Latin5BulgarianModel), 54 | SingleByteCharSetProber(Win1251BulgarianModel), 55 | SingleByteCharSetProber(Latin2HungarianModel), 56 | SingleByteCharSetProber(Win1250HungarianModel), 57 | SingleByteCharSetProber(TIS620ThaiModel), 58 | ] 59 | hebrewProber = HebrewProber() 60 | logicalHebrewProber = SingleByteCharSetProber(Win1255HebrewModel, False, hebrewProber) 61 | visualHebrewProber = SingleByteCharSetProber(Win1255HebrewModel, True, hebrewProber) 62 | hebrewProber.set_model_probers(logicalHebrewProber, visualHebrewProber) 63 | self._mProbers.extend([hebrewProber, logicalHebrewProber, visualHebrewProber]) 64 | 65 | self.reset() 66 | -------------------------------------------------------------------------------- /virtualenv.bundle/requests/packages/chardet2/sjisprober.py: -------------------------------------------------------------------------------- 1 | ######################## BEGIN LICENSE BLOCK ######################## 2 | # The Original Code is mozilla.org code. 3 | # 4 | # The Initial Developer of the Original Code is 5 | # Netscape Communications Corporation. 6 | # Portions created by the Initial Developer are Copyright (C) 1998 7 | # the Initial Developer. All Rights Reserved. 8 | # 9 | # Contributor(s): 10 | # Mark Pilgrim - port to Python 11 | # 12 | # This library is free software; you can redistribute it and/or 13 | # modify it under the terms of the GNU Lesser General Public 14 | # License as published by the Free Software Foundation; either 15 | # version 2.1 of the License, or (at your option) any later version. 16 | # 17 | # This library is distributed in the hope that it will be useful, 18 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 19 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 20 | # Lesser General Public License for more details. 21 | # 22 | # You should have received a copy of the GNU Lesser General Public 23 | # License along with this library; if not, write to the Free Software 24 | # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 25 | # 02110-1301 USA 26 | ######################### END LICENSE BLOCK ######################### 27 | 28 | from .mbcharsetprober import MultiByteCharSetProber 29 | from .codingstatemachine import CodingStateMachine 30 | from .chardistribution import SJISDistributionAnalysis 31 | from .jpcntx import SJISContextAnalysis 32 | from .mbcssm import SJISSMModel 33 | from . import constants 34 | import sys 35 | from .constants import eStart, eError, eItsMe 36 | 37 | class SJISProber(MultiByteCharSetProber): 38 | def __init__(self): 39 | MultiByteCharSetProber.__init__(self) 40 | self._mCodingSM = CodingStateMachine(SJISSMModel) 41 | self._mDistributionAnalyzer = SJISDistributionAnalysis() 42 | self._mContextAnalyzer = SJISContextAnalysis() 43 | self.reset() 44 | 45 | def reset(self): 46 | MultiByteCharSetProber.reset(self) 47 | self._mContextAnalyzer.reset() 48 | 49 | def get_charset_name(self): 50 | return "SHIFT_JIS" 51 | 52 | def feed(self, aBuf): 53 | aLen = len(aBuf) 54 | for i in range(0, aLen): 55 | codingState = self._mCodingSM.next_state(aBuf[i]) 56 | if codingState == eError: 57 | if constants._debug: 58 | sys.stderr.write(self.get_charset_name() + ' prober hit error at byte ' + str(i) + '\n') 59 | self._mState = constants.eNotMe 60 | break 61 | elif codingState == eItsMe: 62 | self._mState = constants.eFoundIt 63 | break 64 | elif codingState == eStart: 65 | charLen = self._mCodingSM.get_current_charlen() 66 | if i == 0: 67 | self._mLastChar[1] = aBuf[0] 68 | self._mContextAnalyzer.feed(self._mLastChar[2 - charLen :], charLen) 69 | self._mDistributionAnalyzer.feed(self._mLastChar, charLen) 70 | else: 71 | self._mContextAnalyzer.feed(aBuf[i + 1 - charLen : i + 3 - charLen], charLen) 72 | self._mDistributionAnalyzer.feed(aBuf[i - 1 : i + 1], charLen) 73 | 74 | self._mLastChar[0] = aBuf[aLen - 1] 75 | 76 | if self.get_state() == constants.eDetecting: 77 | if self._mContextAnalyzer.got_enough_data() and \ 78 | (self.get_confidence() > constants.SHORTCUT_THRESHOLD): 79 | self._mState = constants.eFoundIt 80 | 81 | return self.get_state() 82 | 83 | def get_confidence(self): 84 | contxtCf = self._mContextAnalyzer.get_confidence() 85 | distribCf = self._mDistributionAnalyzer.get_confidence() 86 | return max(contxtCf, distribCf) 87 | -------------------------------------------------------------------------------- /virtualenv.bundle/requests/packages/chardet2/test.py: -------------------------------------------------------------------------------- 1 | from __future__ import print_function 2 | import sys, glob 3 | sys.path.insert(0, '..') 4 | from chardet.universaldetector import UniversalDetector 5 | 6 | count = 0 7 | u = UniversalDetector() 8 | for f in glob.glob(sys.argv[1]): 9 | print(f.ljust(60), end=' ') 10 | u.reset() 11 | for line in open(f, 'rb'): 12 | u.feed(line) 13 | if u.done: break 14 | u.close() 15 | result = u.result 16 | if result['encoding']: 17 | print(result['encoding'], 'with confidence', result['confidence']) 18 | else: 19 | print('******** no result') 20 | count += 1 21 | print(count, 'tests') 22 | -------------------------------------------------------------------------------- /virtualenv.bundle/requests/packages/chardet2/utf8prober.py: -------------------------------------------------------------------------------- 1 | ######################## BEGIN LICENSE BLOCK ######################## 2 | # The Original Code is mozilla.org code. 3 | # 4 | # The Initial Developer of the Original Code is 5 | # Netscape Communications Corporation. 6 | # Portions created by the Initial Developer are Copyright (C) 1998 7 | # the Initial Developer. All Rights Reserved. 8 | # 9 | # Contributor(s): 10 | # Mark Pilgrim - port to Python 11 | # 12 | # This library is free software; you can redistribute it and/or 13 | # modify it under the terms of the GNU Lesser General Public 14 | # License as published by the Free Software Foundation; either 15 | # version 2.1 of the License, or (at your option) any later version. 16 | # 17 | # This library is distributed in the hope that it will be useful, 18 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 19 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 20 | # Lesser General Public License for more details. 21 | # 22 | # You should have received a copy of the GNU Lesser General Public 23 | # License along with this library; if not, write to the Free Software 24 | # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 25 | # 02110-1301 USA 26 | ######################### END LICENSE BLOCK ######################### 27 | 28 | from . import constants 29 | import sys 30 | from .constants import eStart, eError, eItsMe 31 | from .charsetprober import CharSetProber 32 | from .codingstatemachine import CodingStateMachine 33 | from .mbcssm import UTF8SMModel 34 | 35 | ONE_CHAR_PROB = 0.5 36 | 37 | class UTF8Prober(CharSetProber): 38 | def __init__(self): 39 | CharSetProber.__init__(self) 40 | self._mCodingSM = CodingStateMachine(UTF8SMModel) 41 | self.reset() 42 | 43 | def reset(self): 44 | CharSetProber.reset(self) 45 | self._mCodingSM.reset() 46 | self._mNumOfMBChar = 0 47 | 48 | def get_charset_name(self): 49 | return "utf-8" 50 | 51 | def feed(self, aBuf): 52 | for c in aBuf: 53 | codingState = self._mCodingSM.next_state(c) 54 | if codingState == eError: 55 | self._mState = constants.eNotMe 56 | break 57 | elif codingState == eItsMe: 58 | self._mState = constants.eFoundIt 59 | break 60 | elif codingState == eStart: 61 | if self._mCodingSM.get_current_charlen() >= 2: 62 | self._mNumOfMBChar += 1 63 | 64 | if self.get_state() == constants.eDetecting: 65 | if self.get_confidence() > constants.SHORTCUT_THRESHOLD: 66 | self._mState = constants.eFoundIt 67 | 68 | return self.get_state() 69 | 70 | def get_confidence(self): 71 | unlike = 0.99 72 | if self._mNumOfMBChar < 6: 73 | for i in range(0, self._mNumOfMBChar): 74 | unlike = unlike * ONE_CHAR_PROB 75 | return 1.0 - unlike 76 | else: 77 | return unlike 78 | -------------------------------------------------------------------------------- /virtualenv.bundle/requests/packages/oauthlib/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vfasky/BlogCatke/6bb4971c5af88f3edd88c6728561728f64316e18/virtualenv.bundle/requests/packages/oauthlib/__init__.py -------------------------------------------------------------------------------- /virtualenv.bundle/requests/packages/oauthlib/__init__.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vfasky/BlogCatke/6bb4971c5af88f3edd88c6728561728f64316e18/virtualenv.bundle/requests/packages/oauthlib/__init__.pyc -------------------------------------------------------------------------------- /virtualenv.bundle/requests/packages/oauthlib/common.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vfasky/BlogCatke/6bb4971c5af88f3edd88c6728561728f64316e18/virtualenv.bundle/requests/packages/oauthlib/common.pyc -------------------------------------------------------------------------------- /virtualenv.bundle/requests/packages/oauthlib/oauth1/__init__.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | from __future__ import absolute_import 3 | 4 | """ 5 | oauthlib.oauth1 6 | ~~~~~~~~~~~~~~ 7 | 8 | This module is a wrapper for the most recent implementation of OAuth 1.0 Client 9 | and Server classes. 10 | """ 11 | 12 | from .rfc5849 import Client, Server 13 | 14 | -------------------------------------------------------------------------------- /virtualenv.bundle/requests/packages/oauthlib/oauth1/__init__.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vfasky/BlogCatke/6bb4971c5af88f3edd88c6728561728f64316e18/virtualenv.bundle/requests/packages/oauthlib/oauth1/__init__.pyc -------------------------------------------------------------------------------- /virtualenv.bundle/requests/packages/oauthlib/oauth1/rfc5849/__init__.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vfasky/BlogCatke/6bb4971c5af88f3edd88c6728561728f64316e18/virtualenv.bundle/requests/packages/oauthlib/oauth1/rfc5849/__init__.pyc -------------------------------------------------------------------------------- /virtualenv.bundle/requests/packages/oauthlib/oauth1/rfc5849/parameters.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vfasky/BlogCatke/6bb4971c5af88f3edd88c6728561728f64316e18/virtualenv.bundle/requests/packages/oauthlib/oauth1/rfc5849/parameters.pyc -------------------------------------------------------------------------------- /virtualenv.bundle/requests/packages/oauthlib/oauth1/rfc5849/signature.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vfasky/BlogCatke/6bb4971c5af88f3edd88c6728561728f64316e18/virtualenv.bundle/requests/packages/oauthlib/oauth1/rfc5849/signature.pyc -------------------------------------------------------------------------------- /virtualenv.bundle/requests/packages/oauthlib/oauth1/rfc5849/utils.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | 3 | """ 4 | oauthlib.utils 5 | ~~~~~~~~~~~~~~ 6 | 7 | This module contains utility methods used by various parts of the OAuth 8 | spec. 9 | """ 10 | 11 | import string 12 | import urllib2 13 | 14 | from oauthlib.common import quote, unquote 15 | 16 | UNICODE_ASCII_CHARACTER_SET = (string.ascii_letters.decode('ascii') + 17 | string.digits.decode('ascii')) 18 | 19 | 20 | def filter_params(target): 21 | """Decorator which filters params to remove non-oauth_* parameters 22 | 23 | Assumes the decorated method takes a params dict or list of tuples as its 24 | first argument. 25 | """ 26 | def wrapper(params, *args, **kwargs): 27 | params = filter_oauth_params(params) 28 | return target(params, *args, **kwargs) 29 | 30 | wrapper.__doc__ = target.__doc__ 31 | return wrapper 32 | 33 | 34 | def filter_oauth_params(params): 35 | """Removes all non oauth parameters from a dict or a list of params.""" 36 | is_oauth = lambda kv: kv[0].startswith(u"oauth_") 37 | if isinstance(params, dict): 38 | return filter(is_oauth, params.items()) 39 | else: 40 | return filter(is_oauth, params) 41 | 42 | 43 | def escape(u): 44 | """Escape a unicode string in an OAuth-compatible fashion. 45 | 46 | Per `section 3.6`_ of the spec. 47 | 48 | .. _`section 3.6`: http://tools.ietf.org/html/rfc5849#section-3.6 49 | 50 | """ 51 | if not isinstance(u, unicode): 52 | raise ValueError('Only unicode objects are escapable.') 53 | # Letters, digits, and the characters '_.-' are already treated as safe 54 | # by urllib.quote(). We need to add '~' to fully support rfc5849. 55 | return quote(u, safe='~') 56 | 57 | 58 | def unescape(u): 59 | if not isinstance(u, unicode): 60 | raise ValueError('Only unicode objects are unescapable.') 61 | return unquote(u) 62 | 63 | 64 | def urlencode(query): 65 | """Encode a sequence of two-element tuples or dictionary into a URL query string. 66 | 67 | Operates using an OAuth-safe escape() method, in contrast to urllib.urlencode. 68 | """ 69 | # Convert dictionaries to list of tuples 70 | if isinstance(query, dict): 71 | query = query.items() 72 | return u"&".join([u'='.join([escape(k), escape(v)]) for k, v in query]) 73 | 74 | 75 | def parse_keqv_list(l): 76 | """A unicode-safe version of urllib2.parse_keqv_list""" 77 | encoded_list = [u.encode('utf-8') for u in l] 78 | encoded_parsed = urllib2.parse_keqv_list(encoded_list) 79 | return dict((k.decode('utf-8'), 80 | v.decode('utf-8')) for k, v in encoded_parsed.items()) 81 | 82 | 83 | def parse_http_list(u): 84 | """A unicode-safe version of urllib2.parse_http_list""" 85 | encoded_str = u.encode('utf-8') 86 | encoded_list = urllib2.parse_http_list(encoded_str) 87 | return [s.decode('utf-8') for s in encoded_list] 88 | 89 | 90 | def parse_authorization_header(authorization_header): 91 | """Parse an OAuth authorization header into a list of 2-tuples""" 92 | auth_scheme = u'OAuth ' 93 | if authorization_header.startswith(auth_scheme): 94 | authorization_header = authorization_header.replace(auth_scheme, u'', 1) 95 | items = parse_http_list(authorization_header) 96 | try: 97 | return parse_keqv_list(items).items() 98 | except ValueError: 99 | raise ValueError('Malformed authorization header') 100 | -------------------------------------------------------------------------------- /virtualenv.bundle/requests/packages/oauthlib/oauth1/rfc5849/utils.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vfasky/BlogCatke/6bb4971c5af88f3edd88c6728561728f64316e18/virtualenv.bundle/requests/packages/oauthlib/oauth1/rfc5849/utils.pyc -------------------------------------------------------------------------------- /virtualenv.bundle/requests/packages/oauthlib/oauth2/__init__.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | from __future__ import absolute_import 3 | 4 | """ 5 | oauthlib.oauth2 6 | ~~~~~~~~~~~~~~ 7 | 8 | This module is a wrapper for the most recent implementation of OAuth 2.0 Client 9 | and Server classes. 10 | """ 11 | 12 | from .draft25 import Client, Server 13 | 14 | -------------------------------------------------------------------------------- /virtualenv.bundle/requests/packages/oauthlib/oauth2/draft25/tokens.py: -------------------------------------------------------------------------------- 1 | from __future__ import absolute_import 2 | """ 3 | oauthlib.oauth2.draft25.tokens 4 | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5 | 6 | This module contains methods for adding two types of access tokens to requests. 7 | 8 | - Bearer http://tools.ietf.org/html/draft-ietf-oauth-saml2-bearer-08 9 | - MAC http://tools.ietf.org/html/draft-ietf-oauth-v2-http-mac-00 10 | 11 | """ 12 | from binascii import b2a_base64 13 | import hashlib 14 | import hmac 15 | from urlparse import urlparse 16 | 17 | from oauthlib.common import add_params_to_uri, add_params_to_qs 18 | from . import utils 19 | 20 | 21 | def prepare_mac_header(token, uri, key, http_method, nonce=None, headers=None, 22 | body=None, ext=u'', hash_algorithm=u'hmac-sha-1'): 23 | """Add an `MAC Access Authentication`_ signature to headers. 24 | 25 | Unlike OAuth 1, this HMAC signature does not require inclusion of the request 26 | payload/body, neither does it use a combination of client_secret and 27 | token_secret but rather a mac_key provided together with the access token. 28 | 29 | Currently two algorithms are supported, "hmac-sha-1" and "hmac-sha-256", 30 | `extension algorithms`_ are not supported. 31 | 32 | Example MAC Authorization header, linebreaks added for clarity 33 | 34 | Authorization: MAC id="h480djs93hd8", 35 | nonce="1336363200:dj83hs9s", 36 | mac="bhCQXTVyfj5cmA9uKkPFx1zeOXM=" 37 | 38 | .. _`MAC Access Authentication`: http://tools.ietf.org/html/draft-ietf-oauth-v2-http-mac-01 39 | .. _`extension algorithms`: http://tools.ietf.org/html/draft-ietf-oauth-v2-http-mac-01#section-7.1 40 | 41 | :param uri: Request URI. 42 | :param headers: Request headers as a dictionary. 43 | :param http_method: HTTP Request method. 44 | :param key: MAC given provided by token endpoint. 45 | :param algorithm: HMAC algorithm provided by token endpoint. 46 | :return: headers dictionary with the authorization field added. 47 | """ 48 | http_method = http_method.upper() 49 | host, port = utils.host_from_uri(uri) 50 | 51 | if hash_algorithm.lower() == u'hmac-sha-1': 52 | h = hashlib.sha1 53 | else: 54 | h = hashlib.sha256 55 | 56 | nonce = nonce or u'{0}:{1}'.format(utils.generate_nonce(), utils.generate_timestamp()) 57 | sch, net, path, par, query, fra = urlparse(uri) 58 | 59 | if query: 60 | request_uri = path + u'?' + query 61 | else: 62 | request_uri = path 63 | 64 | # Hash the body/payload 65 | if body is not None: 66 | bodyhash = b2a_base64(h(body).digest())[:-1].decode('utf-8') 67 | else: 68 | bodyhash = u'' 69 | 70 | # Create the normalized base string 71 | base = [] 72 | base.append(nonce) 73 | base.append(http_method.upper()) 74 | base.append(request_uri) 75 | base.append(host) 76 | base.append(port) 77 | base.append(bodyhash) 78 | base.append(ext) 79 | base_string = '\n'.join(base) + u'\n' 80 | 81 | # hmac struggles with unicode strings - http://bugs.python.org/issue5285 82 | if isinstance(key, unicode): 83 | key = key.encode('utf-8') 84 | sign = hmac.new(key, base_string, h) 85 | sign = b2a_base64(sign.digest())[:-1].decode('utf-8') 86 | 87 | header = [] 88 | header.append(u'MAC id="%s"' % token) 89 | header.append(u'nonce="%s"' % nonce) 90 | if bodyhash: 91 | header.append(u'bodyhash="%s"' % bodyhash) 92 | if ext: 93 | header.append(u'ext="%s"' % ext) 94 | header.append(u'mac="%s"' % sign) 95 | 96 | headers = headers or {} 97 | headers[u'Authorization'] = u', '.join(header) 98 | return headers 99 | 100 | 101 | def prepare_bearer_uri(token, uri): 102 | """Add a `Bearer Token`_ to the request URI. 103 | Not recommended, use only if client can't use authorization header or body. 104 | 105 | http://www.example.com/path?access_token=h480djs93hd8 106 | 107 | .. _`Bearer Token`: http://tools.ietf.org/html/draft-ietf-oauth-v2-bearer-18 108 | """ 109 | return add_params_to_uri(uri, [((u'access_token', token))]) 110 | 111 | 112 | def prepare_bearer_headers(token, headers=None): 113 | """Add a `Bearer Token`_ to the request URI. 114 | Recommended method of passing bearer tokens. 115 | 116 | Authorization: Bearer h480djs93hd8 117 | 118 | .. _`Bearer Token`: http://tools.ietf.org/html/draft-ietf-oauth-v2-bearer-18 119 | """ 120 | headers = headers or {} 121 | headers[u'Authorization'] = u'Bearer %s' % token 122 | return headers 123 | 124 | 125 | def prepare_bearer_body(token, body=u''): 126 | """Add a `Bearer Token`_ to the request body. 127 | 128 | access_token=h480djs93hd8 129 | 130 | .. _`Bearer Token`: http://tools.ietf.org/html/draft-ietf-oauth-v2-bearer-18 131 | """ 132 | return add_params_to_qs(body, [((u'access_token', token))]) 133 | -------------------------------------------------------------------------------- /virtualenv.bundle/requests/packages/oauthlib/oauth2/draft25/utils.py: -------------------------------------------------------------------------------- 1 | """ 2 | oauthlib.utils 3 | ~~~~~~~~~~~~~~ 4 | 5 | This module contains utility methods used by various parts of the OAuth 2 spec. 6 | """ 7 | 8 | import urllib 9 | import urlparse 10 | 11 | 12 | def host_from_uri(uri): 13 | """Extract hostname and port from URI. 14 | 15 | Will use default port for HTTP and HTTPS if none is present in the URI. 16 | """ 17 | default_ports = { 18 | u'HTTP': u'80', 19 | u'HTTPS': u'443', 20 | } 21 | 22 | sch, netloc, path, par, query, fra = urlparse.urlparse(uri) 23 | if u':' in netloc: 24 | netloc, port = netloc.split(u':', 1) 25 | else: 26 | port = default_ports.get(sch.upper()) 27 | 28 | return netloc, port 29 | 30 | 31 | def escape(u): 32 | """Escape a string in an OAuth-compatible fashion. 33 | 34 | TODO: verify whether this can in fact be used for OAuth 2 35 | 36 | """ 37 | if not isinstance(u, unicode): 38 | raise ValueError('Only unicode objects are escapable.') 39 | return urllib.quote(u.encode('utf-8'), safe='~') 40 | -------------------------------------------------------------------------------- /virtualenv.bundle/requests/packages/urllib3/__init__.py: -------------------------------------------------------------------------------- 1 | # urllib3/__init__.py 2 | # Copyright 2008-2012 Andrey Petrov and contributors (see CONTRIBUTORS.txt) 3 | # 4 | # This module is part of urllib3 and is released under 5 | # the MIT License: http://www.opensource.org/licenses/mit-license.php 6 | 7 | """ 8 | urllib3 - Thread-safe connection pooling and re-using. 9 | """ 10 | 11 | __author__ = 'Andrey Petrov (andrey.petrov@shazow.net)' 12 | __license__ = 'MIT' 13 | __version__ = 'dev' 14 | 15 | 16 | from .connectionpool import ( 17 | HTTPConnectionPool, 18 | HTTPSConnectionPool, 19 | connection_from_url 20 | ) 21 | 22 | from . import exceptions 23 | from .filepost import encode_multipart_formdata 24 | from .poolmanager import PoolManager, ProxyManager, proxy_from_url 25 | from .response import HTTPResponse 26 | from .util import make_headers, get_host 27 | 28 | 29 | # Set default logging handler to avoid "No handler found" warnings. 30 | import logging 31 | try: # Python 2.7+ 32 | from logging import NullHandler 33 | except ImportError: 34 | class NullHandler(logging.Handler): 35 | def emit(self, record): 36 | pass 37 | 38 | logging.getLogger(__name__).addHandler(NullHandler()) 39 | 40 | def add_stderr_logger(level=logging.DEBUG): 41 | """ 42 | Helper for quickly adding a StreamHandler to the logger. Useful for 43 | debugging. 44 | 45 | Returns the handler after adding it. 46 | """ 47 | # This method needs to be in this __init__.py to get the __name__ correct 48 | # even if urllib3 is vendored within another package. 49 | logger = logging.getLogger(__name__) 50 | handler = logging.StreamHandler() 51 | handler.setFormatter(logging.Formatter('%(asctime)s %(levelname)s %(message)s')) 52 | logger.addHandler(handler) 53 | logger.setLevel(level) 54 | logger.debug('Added an stderr logging handler to logger: %s' % __name__) 55 | return handler 56 | 57 | # ... Clean up. 58 | del NullHandler 59 | -------------------------------------------------------------------------------- /virtualenv.bundle/requests/packages/urllib3/__init__.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vfasky/BlogCatke/6bb4971c5af88f3edd88c6728561728f64316e18/virtualenv.bundle/requests/packages/urllib3/__init__.pyc -------------------------------------------------------------------------------- /virtualenv.bundle/requests/packages/urllib3/_collections.py: -------------------------------------------------------------------------------- 1 | # urllib3/_collections.py 2 | # Copyright 2008-2012 Andrey Petrov and contributors (see CONTRIBUTORS.txt) 3 | # 4 | # This module is part of urllib3 and is released under 5 | # the MIT License: http://www.opensource.org/licenses/mit-license.php 6 | 7 | from collections import MutableMapping 8 | from threading import Lock 9 | 10 | try: # Python 2.7+ 11 | from collections import OrderedDict 12 | except ImportError: 13 | from .packages.ordered_dict import OrderedDict 14 | 15 | 16 | __all__ = ['RecentlyUsedContainer'] 17 | 18 | 19 | _Null = object() 20 | 21 | 22 | class RecentlyUsedContainer(MutableMapping): 23 | """ 24 | Provides a thread-safe dict-like container which maintains up to 25 | ``maxsize`` keys while throwing away the least-recently-used keys beyond 26 | ``maxsize``. 27 | 28 | :param maxsize: 29 | Maximum number of recent elements to retain. 30 | 31 | :param dispose_func: 32 | Every time an item is evicted from the container, 33 | ``dispose_func(value)`` is called. Callback which will get called 34 | """ 35 | 36 | ContainerCls = OrderedDict 37 | 38 | def __init__(self, maxsize=10, dispose_func=None): 39 | self._maxsize = maxsize 40 | self.dispose_func = dispose_func 41 | 42 | self._container = self.ContainerCls() 43 | self._lock = Lock() 44 | 45 | def __getitem__(self, key): 46 | # Re-insert the item, moving it to the end of the eviction line. 47 | with self._lock: 48 | item = self._container.pop(key) 49 | self._container[key] = item 50 | return item 51 | 52 | def __setitem__(self, key, value): 53 | evicted_value = _Null 54 | with self._lock: 55 | # Possibly evict the existing value of 'key' 56 | evicted_value = self._container.get(key, _Null) 57 | self._container[key] = value 58 | 59 | # If we didn't evict an existing value, we might have to evict the 60 | # least recently used item from the beginning of the container. 61 | if len(self._container) > self._maxsize: 62 | _key, evicted_value = self._container.popitem(last=False) 63 | 64 | if self.dispose_func and evicted_value is not _Null: 65 | self.dispose_func(evicted_value) 66 | 67 | def __delitem__(self, key): 68 | with self._lock: 69 | value = self._container.pop(key) 70 | 71 | if self.dispose_func: 72 | self.dispose_func(value) 73 | 74 | def __len__(self): 75 | with self._lock: 76 | return len(self._container) 77 | 78 | def __iter__(self): 79 | raise NotImplementedError('Iteration over this class is unlikely to be threadsafe.') 80 | 81 | def clear(self): 82 | with self._lock: 83 | # Copy pointers to all values, then wipe the mapping 84 | # under Python 2, this copies the list of values twice :-| 85 | values = list(self._container.values()) 86 | self._container.clear() 87 | 88 | if self.dispose_func: 89 | for value in values: 90 | self.dispose_func(value) 91 | 92 | def keys(self): 93 | with self._lock: 94 | return self._container.keys() 95 | -------------------------------------------------------------------------------- /virtualenv.bundle/requests/packages/urllib3/_collections.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vfasky/BlogCatke/6bb4971c5af88f3edd88c6728561728f64316e18/virtualenv.bundle/requests/packages/urllib3/_collections.pyc -------------------------------------------------------------------------------- /virtualenv.bundle/requests/packages/urllib3/connectionpool.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vfasky/BlogCatke/6bb4971c5af88f3edd88c6728561728f64316e18/virtualenv.bundle/requests/packages/urllib3/connectionpool.pyc -------------------------------------------------------------------------------- /virtualenv.bundle/requests/packages/urllib3/exceptions.py: -------------------------------------------------------------------------------- 1 | # urllib3/exceptions.py 2 | # Copyright 2008-2012 Andrey Petrov and contributors (see CONTRIBUTORS.txt) 3 | # 4 | # This module is part of urllib3 and is released under 5 | # the MIT License: http://www.opensource.org/licenses/mit-license.php 6 | 7 | 8 | ## Base Exceptions 9 | 10 | class HTTPError(Exception): 11 | "Base exception used by this module." 12 | pass 13 | 14 | 15 | class PoolError(HTTPError): 16 | "Base exception for errors caused within a pool." 17 | def __init__(self, pool, message): 18 | self.pool = pool 19 | HTTPError.__init__(self, "%s: %s" % (pool, message)) 20 | 21 | 22 | class SSLError(HTTPError): 23 | "Raised when SSL certificate fails in an HTTPS connection." 24 | pass 25 | 26 | 27 | class DecodeError(HTTPError): 28 | "Raised when automatic decoding based on Content-Type fails." 29 | pass 30 | 31 | 32 | ## Leaf Exceptions 33 | 34 | class MaxRetryError(PoolError): 35 | "Raised when the maximum number of retries is exceeded." 36 | 37 | def __init__(self, pool, url): 38 | message = "Max retries exceeded with url: %s" % url 39 | PoolError.__init__(self, pool, message) 40 | 41 | self.url = url 42 | 43 | 44 | class HostChangedError(PoolError): 45 | "Raised when an existing pool gets a request for a foreign host." 46 | 47 | def __init__(self, pool, url, retries=3): 48 | message = "Tried to open a foreign host with url: %s" % url 49 | PoolError.__init__(self, pool, message) 50 | 51 | self.url = url 52 | self.retries = retries 53 | 54 | 55 | class TimeoutError(PoolError): 56 | "Raised when a socket timeout occurs." 57 | pass 58 | 59 | 60 | class EmptyPoolError(PoolError): 61 | "Raised when a pool runs out of connections and no more are allowed." 62 | pass 63 | 64 | 65 | class ClosedPoolError(PoolError): 66 | "Raised when a request enters a pool after the pool has been closed." 67 | pass 68 | 69 | 70 | class LocationParseError(ValueError, HTTPError): 71 | "Raised when get_host or similar fails to parse the URL input." 72 | 73 | def __init__(self, location): 74 | message = "Failed to parse: %s" % location 75 | super(LocationParseError, self).__init__(self, message) 76 | 77 | self.location = location 78 | -------------------------------------------------------------------------------- /virtualenv.bundle/requests/packages/urllib3/exceptions.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vfasky/BlogCatke/6bb4971c5af88f3edd88c6728561728f64316e18/virtualenv.bundle/requests/packages/urllib3/exceptions.pyc -------------------------------------------------------------------------------- /virtualenv.bundle/requests/packages/urllib3/filepost.py: -------------------------------------------------------------------------------- 1 | # urllib3/filepost.py 2 | # Copyright 2008-2012 Andrey Petrov and contributors (see CONTRIBUTORS.txt) 3 | # 4 | # This module is part of urllib3 and is released under 5 | # the MIT License: http://www.opensource.org/licenses/mit-license.php 6 | 7 | import codecs 8 | import mimetypes 9 | 10 | from uuid import uuid4 11 | from io import BytesIO 12 | 13 | from .packages import six 14 | from .packages.six import b 15 | 16 | writer = codecs.lookup('utf-8')[3] 17 | 18 | 19 | def choose_boundary(): 20 | """ 21 | Our embarassingly-simple replacement for mimetools.choose_boundary. 22 | """ 23 | return uuid4().hex 24 | 25 | 26 | def get_content_type(filename): 27 | return mimetypes.guess_type(filename)[0] or 'application/octet-stream' 28 | 29 | 30 | def iter_fields(fields): 31 | """ 32 | Iterate over fields. 33 | 34 | Supports list of (k, v) tuples and dicts. 35 | """ 36 | if isinstance(fields, dict): 37 | return ((k, v) for k, v in six.iteritems(fields)) 38 | 39 | return ((k, v) for k, v in fields) 40 | 41 | 42 | def encode_multipart_formdata(fields, boundary=None): 43 | """ 44 | Encode a dictionary of ``fields`` using the multipart/form-data mime format. 45 | 46 | :param fields: 47 | Dictionary of fields or list of (key, value) field tuples. The key is 48 | treated as the field name, and the value as the body of the form-data 49 | bytes. If the value is a tuple of two elements, then the first element 50 | is treated as the filename of the form-data section. 51 | 52 | Field names and filenames must be unicode. 53 | 54 | :param boundary: 55 | If not specified, then a random boundary will be generated using 56 | :func:`mimetools.choose_boundary`. 57 | """ 58 | body = BytesIO() 59 | if boundary is None: 60 | boundary = choose_boundary() 61 | 62 | for fieldname, value in iter_fields(fields): 63 | body.write(b('--%s\r\n' % (boundary))) 64 | 65 | if isinstance(value, tuple): 66 | filename, data = value 67 | writer(body).write('Content-Disposition: form-data; name="%s"; ' 68 | 'filename="%s"\r\n' % (fieldname, filename)) 69 | body.write(b('Content-Type: %s\r\n\r\n' % 70 | (get_content_type(filename)))) 71 | else: 72 | data = value 73 | writer(body).write('Content-Disposition: form-data; name="%s"\r\n' 74 | % (fieldname)) 75 | body.write(b'Content-Type: text/plain\r\n\r\n') 76 | 77 | if isinstance(data, int): 78 | data = str(data) # Backwards compatibility 79 | 80 | if isinstance(data, six.text_type): 81 | writer(body).write(data) 82 | else: 83 | body.write(data) 84 | 85 | body.write(b'\r\n') 86 | 87 | body.write(b('--%s--\r\n' % (boundary))) 88 | 89 | content_type = b('multipart/form-data; boundary=%s' % boundary) 90 | 91 | return body.getvalue(), content_type 92 | -------------------------------------------------------------------------------- /virtualenv.bundle/requests/packages/urllib3/filepost.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vfasky/BlogCatke/6bb4971c5af88f3edd88c6728561728f64316e18/virtualenv.bundle/requests/packages/urllib3/filepost.pyc -------------------------------------------------------------------------------- /virtualenv.bundle/requests/packages/urllib3/packages/__init__.py: -------------------------------------------------------------------------------- 1 | from __future__ import absolute_import 2 | 3 | from . import ssl_match_hostname 4 | 5 | -------------------------------------------------------------------------------- /virtualenv.bundle/requests/packages/urllib3/packages/__init__.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vfasky/BlogCatke/6bb4971c5af88f3edd88c6728561728f64316e18/virtualenv.bundle/requests/packages/urllib3/packages/__init__.pyc -------------------------------------------------------------------------------- /virtualenv.bundle/requests/packages/urllib3/packages/ordered_dict.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vfasky/BlogCatke/6bb4971c5af88f3edd88c6728561728f64316e18/virtualenv.bundle/requests/packages/urllib3/packages/ordered_dict.pyc -------------------------------------------------------------------------------- /virtualenv.bundle/requests/packages/urllib3/packages/six.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vfasky/BlogCatke/6bb4971c5af88f3edd88c6728561728f64316e18/virtualenv.bundle/requests/packages/urllib3/packages/six.pyc -------------------------------------------------------------------------------- /virtualenv.bundle/requests/packages/urllib3/packages/ssl_match_hostname/__init__.py: -------------------------------------------------------------------------------- 1 | """The match_hostname() function from Python 3.2, essential when using SSL.""" 2 | 3 | import re 4 | 5 | __version__ = '3.2.2' 6 | 7 | class CertificateError(ValueError): 8 | pass 9 | 10 | def _dnsname_to_pat(dn): 11 | pats = [] 12 | for frag in dn.split(r'.'): 13 | if frag == '*': 14 | # When '*' is a fragment by itself, it matches a non-empty dotless 15 | # fragment. 16 | pats.append('[^.]+') 17 | else: 18 | # Otherwise, '*' matches any dotless fragment. 19 | frag = re.escape(frag) 20 | pats.append(frag.replace(r'\*', '[^.]*')) 21 | return re.compile(r'\A' + r'\.'.join(pats) + r'\Z', re.IGNORECASE) 22 | 23 | def match_hostname(cert, hostname): 24 | """Verify that *cert* (in decoded format as returned by 25 | SSLSocket.getpeercert()) matches the *hostname*. RFC 2818 rules 26 | are mostly followed, but IP addresses are not accepted for *hostname*. 27 | 28 | CertificateError is raised on failure. On success, the function 29 | returns nothing. 30 | """ 31 | if not cert: 32 | raise ValueError("empty or no certificate") 33 | dnsnames = [] 34 | san = cert.get('subjectAltName', ()) 35 | for key, value in san: 36 | if key == 'DNS': 37 | if _dnsname_to_pat(value).match(hostname): 38 | return 39 | dnsnames.append(value) 40 | if not dnsnames: 41 | # The subject is only checked when there is no dNSName entry 42 | # in subjectAltName 43 | for sub in cert.get('subject', ()): 44 | for key, value in sub: 45 | # XXX according to RFC 2818, the most specific Common Name 46 | # must be used. 47 | if key == 'commonName': 48 | if _dnsname_to_pat(value).match(hostname): 49 | return 50 | dnsnames.append(value) 51 | if len(dnsnames) > 1: 52 | raise CertificateError("hostname %r " 53 | "doesn't match either of %s" 54 | % (hostname, ', '.join(map(repr, dnsnames)))) 55 | elif len(dnsnames) == 1: 56 | raise CertificateError("hostname %r " 57 | "doesn't match %r" 58 | % (hostname, dnsnames[0])) 59 | else: 60 | raise CertificateError("no appropriate commonName or " 61 | "subjectAltName fields were found") 62 | -------------------------------------------------------------------------------- /virtualenv.bundle/requests/packages/urllib3/packages/ssl_match_hostname/__init__.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vfasky/BlogCatke/6bb4971c5af88f3edd88c6728561728f64316e18/virtualenv.bundle/requests/packages/urllib3/packages/ssl_match_hostname/__init__.pyc -------------------------------------------------------------------------------- /virtualenv.bundle/requests/packages/urllib3/poolmanager.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vfasky/BlogCatke/6bb4971c5af88f3edd88c6728561728f64316e18/virtualenv.bundle/requests/packages/urllib3/poolmanager.pyc -------------------------------------------------------------------------------- /virtualenv.bundle/requests/packages/urllib3/request.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vfasky/BlogCatke/6bb4971c5af88f3edd88c6728561728f64316e18/virtualenv.bundle/requests/packages/urllib3/request.pyc -------------------------------------------------------------------------------- /virtualenv.bundle/requests/packages/urllib3/response.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vfasky/BlogCatke/6bb4971c5af88f3edd88c6728561728f64316e18/virtualenv.bundle/requests/packages/urllib3/response.pyc -------------------------------------------------------------------------------- /virtualenv.bundle/requests/packages/urllib3/util.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vfasky/BlogCatke/6bb4971c5af88f3edd88c6728561728f64316e18/virtualenv.bundle/requests/packages/urllib3/util.pyc -------------------------------------------------------------------------------- /virtualenv.bundle/requests/safe_mode.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | 3 | """ 4 | requests.safe_mode 5 | ~~~~~~~~~~~~ 6 | 7 | This module contains a decorator that implements safe_mode. 8 | 9 | :copyright: (c) 2012 by Kenneth Reitz. 10 | :license: ISC, see LICENSE for more details. 11 | 12 | """ 13 | 14 | from .models import Response 15 | from .packages.urllib3.response import HTTPResponse 16 | from .exceptions import RequestException, ConnectionError, HTTPError 17 | import socket 18 | 19 | 20 | def catch_exceptions_if_in_safe_mode(function): 21 | """New implementation of safe_mode. We catch all exceptions at the API level 22 | and then return a blank Response object with the error field filled. This decorator 23 | wraps request() in api.py. 24 | """ 25 | 26 | def wrapped(method, url, **kwargs): 27 | # if save_mode, we catch exceptions and fill error field 28 | if (kwargs.get('config') and kwargs.get('config').get('safe_mode')) or (kwargs.get('session') 29 | and kwargs.get('session').config.get('safe_mode')): 30 | try: 31 | return function(method, url, **kwargs) 32 | except (RequestException, ConnectionError, HTTPError, 33 | socket.timeout, socket.gaierror) as e: 34 | r = Response() 35 | r.error = e 36 | r.raw = HTTPResponse() # otherwise, tests fail 37 | r.status_code = 0 # with this status_code, content returns None 38 | return r 39 | return function(method, url, **kwargs) 40 | return wrapped 41 | -------------------------------------------------------------------------------- /virtualenv.bundle/requests/safe_mode.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vfasky/BlogCatke/6bb4971c5af88f3edd88c6728561728f64316e18/virtualenv.bundle/requests/safe_mode.pyc -------------------------------------------------------------------------------- /virtualenv.bundle/requests/sessions.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vfasky/BlogCatke/6bb4971c5af88f3edd88c6728561728f64316e18/virtualenv.bundle/requests/sessions.pyc -------------------------------------------------------------------------------- /virtualenv.bundle/requests/status_codes.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | 3 | from .structures import LookupDict 4 | 5 | _codes = { 6 | 7 | # Informational. 8 | 100: ('continue',), 9 | 101: ('switching_protocols',), 10 | 102: ('processing',), 11 | 103: ('checkpoint',), 12 | 122: ('uri_too_long', 'request_uri_too_long'), 13 | 200: ('ok', 'okay', 'all_ok', 'all_okay', 'all_good', '\\o/'), 14 | 201: ('created',), 15 | 202: ('accepted',), 16 | 203: ('non_authoritative_info', 'non_authoritative_information'), 17 | 204: ('no_content',), 18 | 205: ('reset_content', 'reset'), 19 | 206: ('partial_content', 'partial'), 20 | 207: ('multi_status', 'multiple_status', 'multi_stati', 'multiple_stati'), 21 | 208: ('im_used',), 22 | 23 | # Redirection. 24 | 300: ('multiple_choices',), 25 | 301: ('moved_permanently', 'moved', '\\o-'), 26 | 302: ('found',), 27 | 303: ('see_other', 'other'), 28 | 304: ('not_modified',), 29 | 305: ('use_proxy',), 30 | 306: ('switch_proxy',), 31 | 307: ('temporary_redirect', 'temporary_moved', 'temporary'), 32 | 308: ('resume_incomplete', 'resume'), 33 | 34 | # Client Error. 35 | 400: ('bad_request', 'bad'), 36 | 401: ('unauthorized',), 37 | 402: ('payment_required', 'payment'), 38 | 403: ('forbidden',), 39 | 404: ('not_found', '-o-'), 40 | 405: ('method_not_allowed', 'not_allowed'), 41 | 406: ('not_acceptable',), 42 | 407: ('proxy_authentication_required', 'proxy_auth', 'proxy_authentication'), 43 | 408: ('request_timeout', 'timeout'), 44 | 409: ('conflict',), 45 | 410: ('gone',), 46 | 411: ('length_required',), 47 | 412: ('precondition_failed', 'precondition'), 48 | 413: ('request_entity_too_large',), 49 | 414: ('request_uri_too_large',), 50 | 415: ('unsupported_media_type', 'unsupported_media', 'media_type'), 51 | 416: ('requested_range_not_satisfiable', 'requested_range', 'range_not_satisfiable'), 52 | 417: ('expectation_failed',), 53 | 418: ('im_a_teapot', 'teapot', 'i_am_a_teapot'), 54 | 422: ('unprocessable_entity', 'unprocessable'), 55 | 423: ('locked',), 56 | 424: ('failed_dependency', 'dependency'), 57 | 425: ('unordered_collection', 'unordered'), 58 | 426: ('upgrade_required', 'upgrade'), 59 | 428: ('precondition_required', 'precondition'), 60 | 429: ('too_many_requests', 'too_many'), 61 | 431: ('header_fields_too_large', 'fields_too_large'), 62 | 444: ('no_response', 'none'), 63 | 449: ('retry_with', 'retry'), 64 | 450: ('blocked_by_windows_parental_controls', 'parental_controls'), 65 | 499: ('client_closed_request',), 66 | 67 | # Server Error. 68 | 500: ('internal_server_error', 'server_error', '/o\\'), 69 | 501: ('not_implemented',), 70 | 502: ('bad_gateway',), 71 | 503: ('service_unavailable', 'unavailable'), 72 | 504: ('gateway_timeout',), 73 | 505: ('http_version_not_supported', 'http_version'), 74 | 506: ('variant_also_negotiates',), 75 | 507: ('insufficient_storage',), 76 | 509: ('bandwidth_limit_exceeded', 'bandwidth'), 77 | 510: ('not_extended',), 78 | } 79 | 80 | codes = LookupDict(name='status_codes') 81 | 82 | for (code, titles) in list(_codes.items()): 83 | for title in titles: 84 | setattr(codes, title, code) 85 | if not title.startswith('\\'): 86 | setattr(codes, title.upper(), code) 87 | -------------------------------------------------------------------------------- /virtualenv.bundle/requests/status_codes.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vfasky/BlogCatke/6bb4971c5af88f3edd88c6728561728f64316e18/virtualenv.bundle/requests/status_codes.pyc -------------------------------------------------------------------------------- /virtualenv.bundle/requests/structures.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | 3 | """ 4 | requests.structures 5 | ~~~~~~~~~~~~~~~~~~~ 6 | 7 | Data structures that power Requests. 8 | 9 | """ 10 | 11 | 12 | class CaseInsensitiveDict(dict): 13 | """Case-insensitive Dictionary 14 | 15 | For example, ``headers['content-encoding']`` will return the 16 | value of a ``'Content-Encoding'`` response header.""" 17 | 18 | @property 19 | def lower_keys(self): 20 | if not hasattr(self, '_lower_keys') or not self._lower_keys: 21 | self._lower_keys = dict((k.lower(), k) for k in list(self.keys())) 22 | return self._lower_keys 23 | 24 | def _clear_lower_keys(self): 25 | if hasattr(self, '_lower_keys'): 26 | self._lower_keys.clear() 27 | 28 | def __setitem__(self, key, value): 29 | dict.__setitem__(self, key, value) 30 | self._clear_lower_keys() 31 | 32 | def __delitem__(self, key): 33 | dict.__delitem__(self, self.lower_keys.get(key.lower(), key)) 34 | self._lower_keys.clear() 35 | 36 | def __contains__(self, key): 37 | return key.lower() in self.lower_keys 38 | 39 | def __getitem__(self, key): 40 | # We allow fall-through here, so values default to None 41 | if key in self: 42 | return dict.__getitem__(self, self.lower_keys[key.lower()]) 43 | 44 | def get(self, key, default=None): 45 | if key in self: 46 | return self[key] 47 | else: 48 | return default 49 | 50 | 51 | class LookupDict(dict): 52 | """Dictionary lookup object.""" 53 | 54 | def __init__(self, name=None): 55 | self.name = name 56 | super(LookupDict, self).__init__() 57 | 58 | def __repr__(self): 59 | return '' % (self.name) 60 | 61 | def __getitem__(self, key): 62 | # We allow fall-through here, so values default to None 63 | 64 | return self.__dict__.get(key, None) 65 | 66 | def get(self, key, default=None): 67 | return self.__dict__.get(key, default) 68 | -------------------------------------------------------------------------------- /virtualenv.bundle/requests/structures.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vfasky/BlogCatke/6bb4971c5af88f3edd88c6728561728f64316e18/virtualenv.bundle/requests/structures.pyc -------------------------------------------------------------------------------- /virtualenv.bundle/requests/utils.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vfasky/BlogCatke/6bb4971c5af88f3edd88c6728561728f64316e18/virtualenv.bundle/requests/utils.pyc -------------------------------------------------------------------------------- /virtualenv.bundle/requirements.txt: -------------------------------------------------------------------------------- 1 | peewee==2.0.2 2 | requests==0.14.1 3 | --------------------------------------------------------------------------------