code stringlengths 1 1.72M | language stringclasses 1
value |
|---|---|
# -*- coding: utf-8 -*-
__author__ = 'gongqf'
from qrcode import *
qr = QRCode(version=1, error_correction=ERROR_CORRECT_H,box_size=12,border=1)
qr.add_data("HS.GDDS-DSZX/G.96/01")
qr.make(fit=True) # Generate the QRCode itself
# im contains a PIL.Image.Image object
im = qr.make_image()
# To save it
im... | Python |
# -*- coding: utf-8 -*-
import requests
import sys
import xlrd
# x 必须用UTF8编码格式,x内容出现 & 符号时,请用 %26 代替,
# 换行符使用 %0A
# 参数 描述 赋值例子
# bg 背景颜色 bg=颜色代码,例如:bg=ffffff
# fg 前景颜色 fg=颜色代码,例如:fg=cc0000
# gc 渐变颜色 gc=颜色代码,例如:gc=cc00000
# el 纠错等级 el可用值:h\q\m\l,例如:el=h
# w 尺寸... | Python |
# -*- coding: utf-8 -*-
__author__ = 'gongqf'
# import win32com
from win32com.client import Dispatch, constants, DispatchEx
from win32com.client.gencache import EnsureDispatch
import shutil
import qrcode
def gen_qr_pic(id,txt=''):
qr = qrcode.QRCode(version=None, error_correction=qrcode.constants.ERRO... | Python |
# -*- coding: utf-8 -*-
from flask.ext.login import login_required, login_user, logout_user, current_user
from login import LoginForm
__author__ = 'gongqf'
import os
import json
from flask import render_template, request, flash, url_for, redirect, jsonify, send_from_directory, make_response, g, \
session
... | Python |
# -*- coding: utf-8 -*-
__author__ = 'gongqf'
from gis import app
app.run(host='0.0.0.0',port=5001,debug=True) | Python |
# -*- coding: utf-8 -*-
__author__ = 'gongqf'
from flask.ext.wtf import Form
from wtforms import TextField, BooleanField
from wtforms.validators import Required
class LoginForm(Form):
openid = TextField('openid', validators = [Required()])
remember_me = BooleanField('remember_me', default = False) | Python |
# -*- coding: utf-8 -*-
from docx import Document
from docx.shared import Inches, Cm
document = Document()
sections=document.sections
print len(sections)
for section in sections:
print section.start_type
table = document.add_table(rows=4, cols=2)
hdr_cells = table.columns[0].cells
hdr_cells[0].text = u'光缆... | Python |
# This file is part of flask_tryton. The COPYRIGHT file at the top level of
# this repository contains the full copyright notices and license terms.
from functools import wraps
from flask import request, current_app
from werkzeug.routing import BaseConverter
from trytond.version import VERSION as trytond_version
tr... | Python |
# This file is part of flask_tryton. The COPYRIGHT file at the top level of
# this repository contains the full copyright notices and license terms.
import os
from setuptools import setup
def read(fname):
return open(os.path.join(os.path.dirname(__file__), fname)).read()
setup(name='flask_tryton',
version='... | Python |
#!/usr/bin/env python
#
# Copyright 2010, Google Inc.
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are
# met:
#
# * Redistributions of source code must retain the above copyright
# notice, this list ... | Python |
"""
Flash Selenium - Python Client
Date: 30 March 2008
Paulo Caroli, Sachin Sudheendra
http://code.google.com/p/flash-selenium
-----------------------------------------
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may o... | Python |
"""
Copyright 2006 ThoughtWorks, Inc.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, sof... | Python |
"""
Flash Selenium - Python Client
Date: 30 March 2008
Paulo Caroli, Sachin Sudheendra
http://code.google.com/p/flash-selenium
-----------------------------------------
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may o... | Python |
"""
Flash Selenium - Python Client
Date: 30 March 2008
Paulo Caroli, Sachin Sudheendra
http://code.google.com/p/flash-selenium
-----------------------------------------
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may o... | Python |
# -*- coding: utf-8 -*-
'''
Created on 2013-4-3
@author: chenkaode@baidu.com
'''
from PyQt4.QtGui import *
from PyQt4.QtCore import *
from PyQt4 import uic
from PyQt4 import QtCore, QtGui
import os,sys
import ui_main
from PathSelectDlg import *
import subprocess
class MainDlg(QDialog,ui_main.Ui_Dialo... | Python |
# -*- coding: utf-8 -*-
# Form implementation generated from reading ui file 'D:\eclipse\eclipseWorkspace\FlashTool\src\main.ui'
#
# Created: Sat Apr 06 23:04:08 2013
# by: PyQt4 UI code generator 4.10
#
# WARNING! All changes made in this file will be lost!
from PyQt4 import QtCore, QtGui
try:
... | Python |
# -*- coding: utf-8 -*-
# Form implementation generated from reading ui file 'D:\eclipse\eclipseWorkspace\FlashTool\src\pathSelectDlg.ui'
#
# Created: Wed Apr 03 11:43:41 2013
# by: PyQt4 UI code generator 4.10
#
# WARNING! All changes made in this file will be lost!
from PyQt4 import QtCore, QtGui
t... | Python |
# -*- coding: utf-8 -*-
# Form implementation generated from reading ui file 'D:\eclipse\eclipseWorkspace\FlashTool\src\pathSelectWidget.ui'
#
# Created: Wed Apr 03 11:28:40 2013
# by: PyQt4 UI code generator 4.10
#
# WARNING! All changes made in this file will be lost!
from PyQt4 import QtCore, QtGui
... | Python |
# -*- coding: utf-8 -*-
# Form implementation generated from reading ui file 'D:\eclipse\eclipseWorkspace\FlashTool\src\main.ui'
#
# Created: Wed Apr 03 11:32:15 2013
# by: PyQt4 UI code generator 4.10
#
# WARNING! All changes made in this file will be lost!
from PyQt4 import QtCore, QtGui
try:
... | Python |
# -*- coding: utf-8 -*-
'''
Created on 2013-4-3
@author: chenkaode@baidu.com
'''
from PyQt4.QtGui import *
import sys
from MainDlg import *
if __name__ == "__main__":
app=QApplication(sys.argv)
dialog=MainDlg()
dialog.show()
app.exec_()
| Python |
# -*- coding: utf-8 -*-
'''
Created on 2013-4-3
@author: chenkaode@baidu.com
'''
from PyQt4.QtGui import *
from PyQt4.QtCore import *
from PyQt4 import uic
from PyQt4 import QtCore, QtGui
import sys
import ui_pathSelect
class PathSelectDlg(QDialog,ui_pathSelect.Ui_selectPathDialog):
def __init__(s... | Python |
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import random
from fabric import Fabric
class UI:
def __init__(self, fabric):
self.fabric = fabric
def start(self):
while True:
print "\n\n"
print "### Que désirez-vous faire ? \n"
print "### 1. Maj interva... | Python |
#!/usr/bin/python
# -*- coding: UTF-8 -
class Message:
def __init__(self, packet):
self.unpack(packet)
def unpack(self, packet):
#header, value = packet.splitlines()
header, value = packet.split("\r\n", 1)
#print "---"
#print value
#print "---"
#value =... | Python |
#!/usr/bin/env python
# -*- coding: utf-8 -*-
INFINITY = 100
MODIFIED = False
class Fib:
"""
Cette classe représente la table de forwarding d'un routeur.
Chaque entrée de la table de forwarding contient:
- La destination.
- Le coût pour joindre cette destination.
- Le premier routeur sur le c... | Python |
#!/usr/bin/env python
# -*- coding: utf-8 -*-
MODIFIED = False
class Fib:
"""
Cette classe représente la table de forwarding d'un routeur.
Chaque entrée de la table de forwarding contient:
- La destination.
- Le coût pour joindre cette destination.
- Le premier routeur sur le chemin.
"""
... | Python |
#!/usr/bin/env python
# -*- coding: utf-8 -*-
from threading import Thread
class Spooler(Thread):
def __init__(self, fabric, data, infos):
Thread.__init__(self)
self.fabric = fabric
self.data = data
self.infos = infos
self.lock = fabric.getLock()
def run(self... | Python |
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import socket
from spooler import Spooler
from threading import Thread
BUFF_SIZE = 1024
class Link(Thread):
def __init__(self, linkConfig, UDPsock, fabric):
"""
Cette fonction crée un lien. Un lien est caractérisé par:
- Une adresse IP (celle... | Python |
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import socket
import random
from fibv2 import Fib
from message import Message
from threading import Lock
from threading import Timer
class Fabric:
def __init__(self, routerName, configuration, interval):
self.routerName = routerName
self.configura... | Python |
#!/usr/bin/env python
# -*- coding: utf-8 -*-
from threading import Thread
class Spooler(Thread):
def __init__(self, fabric, data, infos):
Thread.__init__(self)
self.fabric = fabric
self.data = data
self.infos = infos
self.lock = fabric.getLock()
def run(self... | Python |
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import random
from fabric import Fabric
class UI:
def __init__(self, fabric):
self.fabric = fabric
def start(self):
while True:
print "\n\n"
print "### Que désirez-vous faire ? \n"
print "### 1. Maj interva... | Python |
#!/usr/bin/env python
# -*- coding: utf-8 -*-
from fabric import Fabric
from link import Link
from threading import Timer
from UI import UI
import sys
import socket
class Router:
def extractConfiguration(self, cfile):
"""
Cette fonction extrait les différentes informations
présentent ... | Python |
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import socket
from spooler import Spooler
from threading import Thread
BUFF_SIZE = 1024
class Link(Thread):
def __init__(self, linkConfig, UDPsock, fabric):
"""
Cette fonction crée un lien. Un lien est caractérisé par:
- Une adresse IP (celle... | Python |
#!/usr/bin/env python
# -*- coding: utf-8 -*-
MODIFIED = False
class Fib:
"""
Cette classe représente la table de forwarding d'un routeur.
Chaque entrée de la table de forwarding contient:
- La destination.
- Le coût pour joindre cette destination.
- Le premier routeur sur le chemin.
"""
... | Python |
#!/usr/bin/env python
# -*- coding: utf-8 -*-
INFINITY = 100
MODIFIED = False
class Fib:
"""
Cette classe représente la table de forwarding d'un routeur.
Chaque entrée de la table de forwarding contient:
- La destination.
- Le coût pour joindre cette destination.
- Le premier routeur sur le c... | Python |
#!/usr/bin/python
# -*- coding: UTF-8 -
class Message:
def __init__(self, packet):
self.unpack(packet)
def unpack(self, packet):
#header, value = packet.splitlines()
header, value = packet.split("\r\n", 1)
#print "---"
#print value
#print "---"
#value =... | Python |
#!/usr/bin/env python
# -*- coding: utf-8 -*-
from fabric import Fabric
from link import Link
from threading import Timer
from UI import UI
import sys
import socket
class Router:
def extractConfiguration(self, cfile):
"""
Cette fonction extrait les différentes informations
présentent ... | Python |
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import socket
import random
from fibv2 import Fib
from message import Message
from threading import Lock
from threading import Timer
class Fabric:
def __init__(self, routerName, configuration, interval):
self.routerName = routerName
self.configura... | Python |
# Testloader for setuptools unittest.
# Copyright (C) 2009 Manuel Hermann <manuel-hermann@gmx.net>
#
# This file is part of tinydav.
#
# tinydav is free software: you can redistribute it and/or modify
# it under the terms of the GNU Lesser General Public License as published by
# the Free Software Foundation, either v... | Python |
# Unittests for util module.
# coding: utf-8
# Copyright (C) 2009 Manuel Hermann <manuel-hermann@gmx.net>
#
# This file is part of tinydav.
#
# tinydav is free software: you can redistribute it and/or modify
# it under the terms of the GNU Lesser General Public License as published by
# the Free Software Foundation, e... | Python |
# Unittests for tinydav lib.
# coding: utf-8
# Copyright (C) 2009 Manuel Hermann <manuel-hermann@gmx.net>
#
# This file is part of tinydav.
#
# tinydav is free software: you can redistribute it and/or modify
# it under the terms of the GNU Lesser General Public License as published by
# the Free Software Foundation, e... | Python |
# Unittests for creator module.
# Copyright (C) 2009 Manuel Hermann <manuel-hermann@gmx.net>
#
# This file is part of tinydav.
#
# tinydav is free software: you can redistribute it and/or modify
# it under the terms of the GNU Lesser General Public License as published by
# the Free Software Foundation, either version... | Python |
# Mock object for unittests.
# Copyright (C) 2009 Manuel Hermann <manuel-hermann@gmx.net>
#
# This file is part of tinydav.
#
# tinydav is free software: you can redistribute it and/or modify
# it under the terms of the GNU Lesser General Public License as published by
# the Free Software Foundation, either version 3 ... | Python |
# Unittests for exception module.
# Copyright (C) 2009 Manuel Hermann <manuel-hermann@gmx.net>
#
# This file is part of tinydav.
#
# tinydav is free software: you can redistribute it and/or modify
# it under the terms of the GNU Lesser General Public License as published by
# the Free Software Foundation, either versi... | Python |
# Exceptions for the tinydav WebDAV client.
# Copyright (C) 2009 Manuel Hermann <manuel-hermann@gmx.net>
#
# This file is part of tinydav.
#
# tinydav is free software: you can redistribute it and/or modify
# it under the terms of the GNU Lesser General Public License as published by
# the Free Software Foundation, ei... | Python |
# Utility function for tinydav WebDAV client.
# Copyright (C) 2009 Manuel Hermann <manuel-hermann@gmx.net>
#
# This file is part of tinydav.
#
# tinydav is free software: you can redistribute it and/or modify
# it under the terms of the GNU Lesser General Public License as published by
# the Free Software Foundation, ... | Python |
# The tinydav WebDAV client.
# Copyright (C) 2009 Manuel Hermann <manuel-hermann@gmx.net>
#
# This file is part of tinydav.
#
# tinydav is free software: you can redistribute it and/or modify
# it under the terms of the GNU Lesser General Public License as published by
# the Free Software Foundation, either version 3 ... | Python |
# Request creator function for tinydav WebDAV client.
# Copyright (C) 2009 Manuel Hermann <manuel-hermann@gmx.net>
#
# This file is part of tinydav.
#
# tinydav is free software: you can redistribute it and/or modify
# it under the terms of the GNU Lesser General Public License as published by
# the Free Software Foun... | Python |
#!/usr/bin/python
# coding: utf-8
#
# Copyright (C) 2009 Manuel Hermann <manuel-hermann@gmx.net>
from distutils.core import setup
import tinydav
VERSION = tinydav.__version__
DOWNLOAD = "http://tinydav.googlecode.com/files/tinydav-%s.tar.gz" % VERSION
DESCRIPTION = "An easy-to-use HTTP and WebDAV client library."
LO... | Python |
from sqlalchemy.ext.declarative import declarative_base
BaseModel = declarative_base()
| Python |
from sqlalchemy import create_engine
from sqlalchemy.orm import sessionmaker
import myproject.config as config
engine = create_engine(config.db_url, echo=config.debug)
Session = sessionmaker(bind=engine, expire_on_commit=False)
| Python |
from flask import Flask
import myproject.config as config
from myproject.pbin.views import blueprint as blueprint_pbin
app = Flask("myproject")
app.config.update(config.flask_config)
app.register_blueprint(blueprint_pbin, url_prefix="/pbin")
def main():
app.run(config.web_ip, config.web_port)
... | Python |
import os
import yaml
def load_config(cfg_path):
with open(cfg_path, "r") as f:
params = yaml.load(f)
globals().update(params)
cfg_path = os.path.join(os.path.dirname(__file__), "config.yaml")
load_config(cfg_path)
| Python |
'''
Module which prompts the user for translations and saves them.
TODO: implement
@author: Rodrigo Damazio
'''
class Translator(object):
'''
classdocs
'''
def __init__(self, language):
'''
Constructor
'''
self._language = language
def Translate(self, string_names):
print string_names | Python |
'''
Module which brings history information about files from Mercurial.
@author: Rodrigo Damazio
'''
import re
import subprocess
REVISION_REGEX = re.compile(r'(?P<hash>[0-9a-f]{12}):.*')
def _GetOutputLines(args):
'''
Runs an external process and returns its output as a list of lines.
@param args: the argume... | Python |
'''
Module which parses a string XML file.
@author: Rodrigo Damazio
'''
from xml.parsers.expat import ParserCreate
import re
#import xml.etree.ElementTree as ET
class StringsParser(object):
'''
Parser for string XML files.
This object is not thread-safe and should be used for parsing a single file at
a time... | Python |
#!/usr/bin/python
'''
Entry point for My Tracks i18n tool.
@author: Rodrigo Damazio
'''
import mytracks.files
import mytracks.translate
import mytracks.validate
import sys
def Usage():
print 'Usage: %s <command> [<language> ...]\n' % sys.argv[0]
print 'Commands are:'
print ' cleanup'
print ' translate'
p... | Python |
'''
Module which compares languague files to the master file and detects
issues.
@author: Rodrigo Damazio
'''
import os
from mytracks.parser import StringsParser
import mytracks.history
class Validator(object):
def __init__(self, languages):
'''
Builds a strings file validator.
Params:
@para... | Python |
'''
Module for dealing with resource files (but not their contents).
@author: Rodrigo Damazio
'''
import os.path
from glob import glob
import re
MYTRACKS_RES_DIR = 'MyTracks/res'
ANDROID_MASTER_VALUES = 'values'
ANDROID_VALUES_MASK = 'values-*'
def GetMyTracksDir():
'''
Returns the directory in which the MyTrac... | Python |
import pyglet
import random
import time
from pyglet.window import Window
win = Window(width=640, height=480)
win.set_fullscreen(True)
win.set_mouse_visible(False)
a=True
@win.event
def on_key_press(symbol, modifiers):
win.set_fullscreen(False)
@win.event
def on_draw():
global a
if a=... | Python |
# coding:utf8
import unittest
from unittest import TestCase
from hgwebcommit.actions import Action, ActionManager
class ActionTestCase(TestCase):
"""
Actionのテスト
"""
def test_call(self):
action = Action('test', 'test', lambda :'ok')
self.assertEqual(action(), 'ok')
class ActionManagerT... | Python |
# app
from hgwebcommit import app
# config
SECRET_KEY = '(secret key)'
HGWEBCOMMIT_REPOSITORY = '/path/to/repository'
HGWEBCOMMIT_ENCODING = 'utf-8'
HGWEBCOMMIT_ALLOW_COMMIT = True
# actions
HGWEBCOMMIT_ACTIONS = (
# 'hgwebcommit.actions.hello',
)
if __name__ == '__main__':
app.debug = True
app.config.fr... | Python |
from flaskext.wtf import Form
from flaskext.wtf import SelectMultipleField, IntegerField, HiddenField, TextField, SelectField
from flaskext.wtf import HiddenInput, Required
from flaskext.babel import lazy_gettext as _
class SelectFileForm(Form):
files = SelectMultipleField('Files', validators=[Required()])
class ... | Python |
import os
from mercurial import cmdutil
from mercurial import commands
from mercurial.util import datestr
from mercurial.hg import repository
from mercurial.ui import ui
from mercurial.match import match
from mercurial.node import short
class MercurialWrapper(object):
def __init__(self, path, encoding='utf-8'):
... | Python |
from flask import flash
from flaskext.babel import gettext, lazy_gettext
from hgwebcommit.actions.decorators import action
@action('hello', lazy_gettext('Hello'))
def hello():
flash(gettext('Hello!'))
| Python |
from hgwebcommit.actions import Action, manager
def action(name, label, params=None):
def _wrap(func):
obj = Action(name, label, func, params)
manager.add(obj)
return func
return _wrap
| Python |
# coding:utf-8
from werkzeug import import_string
from hgwebcommit import app
class ActionLoader(object):
def load_actions(self):
action_modules = app.config.get('HGWEBCOMMIT_ACTIONS') or []
for mod_name in action_modules:
mod = import_string(mod_name)
| Python |
class InvalidAction(Exception):
pass
class Action(object):
def __init__(self, name, label, func, params=None):
self.name = name
self.label = label
self.func = func
self.params = params
def __call__(self, *args, **kwargs):
if self.params:
kwargs.update(se... | Python |
from hgwebcommit.actions.base import InvalidAction, Action, ActionManager
from hgwebcommit.actions.loaders import ActionLoader
manager = ActionManager()
loader = ActionLoader()
| Python |
import os
import socket
import logging
from copy import copy
from werkzeug import MultiDict
from flask import Flask, render_template, request, abort, redirect, url_for, session, flash
from flaskext.babel import gettext as _
from flaskext.babel import lazy_gettext
from hgwebcommit import app
from hgwebcommit.hgwrapper... | Python |
from flask import Flask, g, request
from flaskext.babel import Babel
app = Flask(__name__)
babel = Babel(app)
@babel.localeselector
def get_locale():
return request.accept_languages.best_match(['en', 'ja', 'ja_JP'])
import hgwebcommit.views
| Python |
'''
Module which brings history information about files from Mercurial.
@author: Rodrigo Damazio
'''
import re
import subprocess
REVISION_REGEX = re.compile(r'(?P<hash>[0-9a-f]{12}):.*')
def _GetOutputLines(args):
'''
Runs an external process and returns its output as a list of lines.
@param args: the argume... | Python |
#!/usr/bin/python
'''
Entry point for My Tracks i18n tool.
@author: Rodrigo Damazio
'''
import mytracks.files
import mytracks.translate
import mytracks.validate
import sys
def Usage():
print 'Usage: %s <command> [<language> ...]\n' % sys.argv[0]
print 'Commands are:'
print ' cleanup'
print ' translate'
p... | Python |
'''
Module which prompts the user for translations and saves them.
TODO: implement
@author: Rodrigo Damazio
'''
class Translator(object):
'''
classdocs
'''
def __init__(self, language):
'''
Constructor
'''
self._language = language
def Translate(self, string_names):
print string_names | Python |
'''
Module which compares languague files to the master file and detects
issues.
@author: Rodrigo Damazio
'''
import os
from mytracks.parser import StringsParser
import mytracks.history
class Validator(object):
def __init__(self, languages):
'''
Builds a strings file validator.
Params:
@para... | Python |
'''
Module for dealing with resource files (but not their contents).
@author: Rodrigo Damazio
'''
import os.path
from glob import glob
import re
MYTRACKS_RES_DIR = 'MyTracks/res'
ANDROID_MASTER_VALUES = 'values'
ANDROID_VALUES_MASK = 'values-*'
def GetMyTracksDir():
'''
Returns the directory in which the MyTrac... | Python |
'''
Module which parses a string XML file.
@author: Rodrigo Damazio
'''
from xml.parsers.expat import ParserCreate
import re
#import xml.etree.ElementTree as ET
class StringsParser(object):
'''
Parser for string XML files.
This object is not thread-safe and should be used for parsing a single file at
a time... | Python |
# api code for the reviewboard extension, inspired/copied from reviewboard
# post-review code.
import cookielib
import getpass
import mimetools
import os
import urllib2
import simplejson
import mercurial.ui
from urlparse import urljoin, urlparse
class APIError(Exception):
pass
class ReviewBoardError(Exception):
... | Python |
"""Implementation of JSONDecoder
"""
import re
import sys
import struct
from scanner import make_scanner
c_scanstring = None
__all__ = ['JSONDecoder']
FLAGS = re.VERBOSE | re.MULTILINE | re.DOTALL
def _floatconstants():
_BYTES = '7FF80000000000007FF0000000000000'.decode('hex')
if sys.byteorder != 'big':
... | Python |
"""JSON token scanner
"""
import re
c_make_scanner = None
__all__ = ['make_scanner']
NUMBER_RE = re.compile(
r'(-?(?:0|[1-9]\d*))(\.\d+)?([eE][-+]?\d+)?',
(re.VERBOSE | re.MULTILINE | re.DOTALL))
def py_make_scanner(context):
parse_object = context.parse_object
parse_array = context.parse_array
p... | Python |
"""Implementation of JSONEncoder
"""
import re
c_encode_basestring_ascii = None
c_make_encoder = None
ESCAPE = re.compile(r'[\x00-\x1f\\"\b\f\n\r\t]')
ESCAPE_ASCII = re.compile(r'([\\"]|[^\ -~])')
HAS_UTF8 = re.compile(r'[\x80-\xff]')
ESCAPE_DCT = {
'\\': '\\\\',
'"': '\\"',
'\b': '\\b',
'\f': '\\f',
... | Python |
r"""JSON (JavaScript Object Notation) <http://json.org> is a subset of
JavaScript syntax (ECMA-262 3rd edition) used as a lightweight data
interchange format.
:mod:`simplejson` exposes an API familiar to users of the standard library
:mod:`marshal` and :mod:`pickle` modules. It is the externally maintained
version of ... | Python |
'''post changesets to a reviewboard server'''
import os, errno, re
import cStringIO
from distutils.version import LooseVersion
from mercurial import cmdutil, hg, ui, mdiff, patch, util, node
from mercurial.i18n import _
from reviewboard import make_rbclient, ReviewBoardError
def postreview(ui, repo, rev='.', **opts)... | Python |
from flask import Flask, session, request, render_template, views, flash, redirect, url_for
# import flask
app = Flask(__name__)
# генерация ключа для работы с сессией
app.secret_key = "b8l\x0b~\xe3<y\xc5D\xb6v9\'D\xd0y\xeap\x80e\xcb&_\xc27"
@app.route('/', methods=['GET', 'POST'])
def login():
if reques... | Python |
import logging, os
# Google App Engine imports.
from google.appengine.ext.webapp import util
# Force Django to reload its settings.
from django.conf import settings
settings._target = None
# Must set this env var before importing any part of Django
# 'project' is the name of the project created with django... | Python |
from google.appengine.api import users
from google.appengine.ext import db
from django.http import HttpResponse
from project.experts.models import User
def create(request):
experts = '''
Kundan Singh
kundan10@gmail.com
+1-917-621-6392
http://www.google.com
San Francisco, CA, USA
An independent consultant in... | Python |
import random
from google.appengine.ext import db
from django.http import HttpResponseRedirect
from django.shortcuts import render_to_response
from project.experts.views.common import get_login_user, get_url
def _get_popular_topics(max_count=10):
tags = db.GqlQuery('SELECT * FROM Tag ORDER BY count DESC').f... | Python |
import datetime, time, random, logging, sys, traceback
from google.appengine.api import users, channel, xmpp
from google.appengine.ext import db
from django.http import HttpResponse, HttpResponseServerError, HttpResponseForbidden
from django.shortcuts import render_to_response
from django.utils import simplejson as j... | Python |
from google.appengine.api import users
from google.appengine.ext import db
from django.shortcuts import render_to_response
from project.experts.views.common import get_login_user, clean_html
def search_result(user): # what to display in search result
return u'''
<li>
<a href="/experts/%s/calendar" ti... | Python |
from google.appengine.api import users
from project.experts.models import get_current_user
def get_url(request):
return 'http://' + request.META['HTTP_HOST'] + request.META['PATH_INFO'] + request.META['SCRIPT_NAME'] + ('?' + request.META['QUERY_STRING'] if request.META['QUERY_STRING'] else '')
def get_login_user(... | Python |
from google.appengine.api import users, xmpp
from google.appengine.ext import db
from google.appengine.ext.db import djangoforms
from django.http import HttpResponseRedirect
from django.shortcuts import render_to_response
from project import xmpp
from project.experts.models import User, Tag, Review
from project.exper... | Python |
import datetime, calendar
from google.appengine.api import users
from google.appengine.ext import db
from google.appengine.ext.db import djangoforms
from django.shortcuts import render_to_response
from project.experts.models import Event
from project.experts.views.common import get_login_user
from django.http import... | Python |
import datetime
from google.appengine.api import users
from google.appengine.ext import db
class User(db.Model):
name = db.StringProperty('Full Name')
account = db.UserProperty()
phone_number = db.PhoneNumberProperty('Phone Number')
address = db.PostalAddressProperty('Postal Address')
website = db.... | Python |
"""
This file demonstrates two different styles of tests (one doctest and one
unittest). These will both pass when you run "manage.py test".
Replace these with more appropriate tests for your application.
"""
from django.test import TestCase
class SimpleTest(TestCase):
def test_basic_addition(self):
"""
... | Python |
from django.conf.urls.defaults import *
# Uncomment the next two lines to enable the admin:
#from django.contrib import admin
#admin.autodiscover()
urlpatterns = patterns('project.experts.views',
(r'^$', 'main.index'),
(r'^search/', 'search.index'),
(r'^(?P<account>[^\/]+)/profile/', 'profile.index'),
... | Python |
#!/usr/bin/env python
from django.core.management import execute_manager
try:
import settings # Assumed to be in the same directory.
except ImportError:
import sys
sys.stderr.write("Error: Can't find the file 'settings.py' in the directory containing %r. It appears you've customized things.\nYou'll have to ... | Python |
from google.appengine.ext import db
class Owner(db.Model):
email = db.StringProperty(required=True)
gtalk = db.BooleanProperty(default=True)
def __repr__(self):
return '<Owner email=%r gtalk=%r />'%(self.email, self.gtalk)
class Visitor(db.Model):
clientId = db.StringProperty(required=Tru... | Python |
from django.conf.urls.defaults import *
# Uncomment the next two lines to enable the admin:
#from django.contrib import admin
#admin.autodiscover()
urlpatterns = patterns('project.office.views',
(r'^(?P<owner>[^\/]+)/(?P<command>[^\/]+)/', 'command'),
(r'^(?P<owner>[^\/]+)/$', 'index'),
(r'^', 'redirect')... | Python |
import datetime, time, random, logging, sys, traceback, cgi
from google.appengine.api import users, channel, xmpp
from google.appengine.ext import db
from django.http import HttpResponse, HttpResponseServerError, HttpResponseForbidden, HttpResponseRedirect
from django.shortcuts import render_to_response
from django.u... | Python |
#!/usr/bin/env python
from django.core.management import execute_manager
try:
import settings # Assumed to be in the same directory.
except ImportError:
import sys
sys.stderr.write("Error: Can't find the file 'settings.py' in the directory containing %r. It appears you've customized things.\nYou'll have to ... | Python |
from django.conf.urls.defaults import *
from project.xmpp import xmpp_handler
# Uncomment the next two lines to enable the admin:
#from django.contrib import admin
#admin.autodiscover()
urlpatterns = patterns('',
# Example:
# (r'^chat/', include('project.chat.urls')),
# (r'^random/', include('project.rand... | Python |
Subsets and Splits
SQL Console for ajibawa-2023/Python-Code-Large
Provides a useful breakdown of language distribution in the training data, showing which languages have the most samples and helping identify potential imbalances across different language groups.