code
stringlengths
1
1.72M
language
stringclasses
1 value
#!/usr/bin/python # wedge.py # Copyright (c) 2004, Apple Computer, Inc., all rights reserved. # IMPORTANT: This Apple software is supplied to you by Apple Computer, Inc. ("Apple") in # consideration of your agreement to the following terms, and your use, installation, # modification or redistribution of this Apple s...
Python
#!/usr/bin/python # watermark.py -- add a "watermark" to each page of a pdf document # Copyright (c) 2004, Apple Computer, Inc., all rights reserved. # IMPORTANT: This Apple software is supplied to you by Apple Computer, Inc. ("Apple") in # consideration of your agreement to the following terms, and your use, instal...
Python
#!/usr/bin/python # bitmap.py # Copyright (c) 2004, Apple Computer, Inc., all rights reserved. # IMPORTANT: This Apple software is supplied to you by Apple Computer, Inc. ("Apple") in # consideration of your agreement to the following terms, and your use, installation, # modification or redistribution of this Apple ...
Python
#!/usr/bin/python # contactsheet.py -- create contact sheet from a list of jpg files # Copyright (c) 2004, Apple Computer, Inc., all rights reserved. # IMPORTANT: This Apple software is supplied to you by Apple Computer, Inc. ("Apple") in # consideration of your agreement to the following terms, and your use, instal...
Python
#!/usr/bin/python # watermark.py -- add a "watermark" to each page of a pdf document # Copyright (c) 2004, Apple Computer, Inc., all rights reserved. # IMPORTANT: This Apple software is supplied to you by Apple Computer, Inc. ("Apple") in # consideration of your agreement to the following terms, and your use, instal...
Python
#!/usr/bin/python # filter-pdf.py -- apply a ColorSync Filter to each page of a pdf document # Copyright (c) 2004, Apple Computer, Inc., all rights reserved. # IMPORTANT: This Apple software is supplied to you by Apple Computer, Inc. ("Apple") in # consideration of your agreement to the following terms, and your use...
Python
#!/usr/bin/python # Usage: picttopdf pict-data-file # Copyright (c) 2004, Apple Computer, Inc., all rights reserved. # IMPORTANT: This Apple software is supplied to you by Apple Computer, Inc. ("Apple") in # consideration of your agreement to the following terms, and your use, installation, # modification or redistr...
Python
#!/usr/bin/python # cmyk-bitmap.py # Copyright (c) 2004, Apple Computer, Inc., all rights reserved. # IMPORTANT: This Apple software is supplied to you by Apple Computer, Inc. ("Apple") in # consideration of your agreement to the following terms, and your use, installation, # modification or redistribution of this A...
Python
#!/usr/bin/env python # doc2pdf.py # Copyright (c) 2004, Apple Computer, Inc., all rights reserved. # IMPORTANT: This Apple software is supplied to you by Apple Computer, Inc. ("Apple") in # consideration of your agreement to the following terms, and your use, installation, # modification or redistribution of this A...
Python
#!/usr/bin/python # image.py # Copyright (c) 2004, Apple Computer, Inc., all rights reserved. # IMPORTANT: This Apple software is supplied to you by Apple Computer, Inc. ("Apple") in # consideration of your agreement to the following terms, and your use, installation, # modification or redistribution of this Apple s...
Python
from __future__ import division import numpy as np import sys import analysedata as adata #Find last signal signal recorded during Qin Bin scan. #Set 'dirname' to directory containing files to be analysed. #Set 'indices_select' to choose files by index (indices_select=[] selects all files) #'channel_id' can be used t...
Python
#!/usr/bin/python import matplotlib import glob from pylab import * import numpy as np from analysedata import * from scipy import interpolate #Written by S. Sheehy on 27/3/2014 #Updates: #21/10/2014: Updated to use individual ranges for each probe calculation (S. Sheehy) # matplotlib.rcParams['legend.fontsize']=8 ...
Python
#!/usr/bin/python import matplotlib import glob from pylab import * import numpy as np from analysedata import * #from dispersion_analysis140327 import * matplotlib.rcParams['legend.fontsize']=8 def calcKvalue(t_rf, f_rf, E_rf, tvals, rvals): '''use rvalues and tvals to get k value from rf file''' fvals=...
Python
title = 'Read scope trace' import sys sys.path[:0] = ['../../..'] import os import numpy import scipy import scipy.optimize #import Tkinter import Pmw import time #import shutil import string import pylab as plt import math #from Tkinter import * # # # class Bpm: def __init__(self): global dirname, fi...
Python
#!/usr/bin/python import matplotlib matplotlib.rcParams['font.family'] = 'serif' matplotlib.rcParams['legend.fontsize']=12 from pylab import * from scipy import interpolate import numpy as np import os #DAVID'S READSCOPE FUNCTION def read_scope(dirname, filename, tfactor=1): """Read scope data. The script deals w...
Python
from scipy.signal import butter, lfilter def butter_highpass(cutoff, fs, order=5): '''butterworth highpass filter''' nyq = 0.5 * fs b, a = butter(order, cutoff/nyq, btype='highpass') return b, a def butter_bandpass_filter(data, cutoff, fs, order=5): '''butterworth bandpass filter''' b, a = b...
Python
#!/usr/bin/python import matplotlib matplotlib.rcParams['font.family'] = 'serif' matplotlib.rcParams['legend.fontsize']=12 from pylab import * from scipy import interpolate import numpy as np import os #DAVID'S READSCOPE FUNCTION def read_scope(dirname, filename, tfactor=1): """Read scope data. The script deals w...
Python
#!/usr/bin/python import matplotlib import glob from pylab import * import numpy as np from analysedata import * from scipy import interpolate #Written by S. Sheehy on 27/3/2014 #Updates: #21/10/2014: Updated to use individual ranges for each probe calculation (S. Sheehy) # matplotlib.rcParams['legend.fontsize']=8 ...
Python
#!/usr/bin/python import matplotlib import glob from pylab import * import numpy as np from analysedata import * #from dispersion_analysis140327 import * matplotlib.rcParams['legend.fontsize']=8 def calcKvalue(t_rf, f_rf, E_rf, tvals, rvals): '''use rvalues and tvals to get k value from rf file''' fvals=...
Python
#==================================================================== # Licensed to the Apache Software Foundation (ASF) under one # or more contributor license agreements. See the NOTICE file # distributed with this work for additional information # regarding copyright ownership. The ASF licenses this file # to you ...
Python
#!/usr/bin/python2 # coding: utf-8 import psycopg2 def update_grp(grp_db): conn = psycopg2.connect(database="ff_schedule", user="postgres", password="postgres") cur = conn.cursor() cur.execute("DROP TABLE IF EXISTS groups;") cur.execute("CREATE TABLE groups (id SERIAL, group_no smallint, subgroup_no smallint, spe...
Python
#!/usr/bin/python2 # -*- coding: utf-8 -*- import sys,os,xmpp,time,select,string,re import db_oper class Bot: def __init__(self,jabber): self.jabber = jabber # self.remotejid = remotejid def register_handlers(self): self.jabber.RegisterHandler('message',self.xmpp_message) self...
Python
#!/usr/bin/python2 # coding: utf-8 import psycopg2 def update_grp(grp_db): conn = psycopg2.connect(database="ff_schedule", user="postgres", password="postgres") cur = conn.cursor() cur.execute("DROP TABLE IF EXISTS groups;") cur.execute("CREATE TABLE groups (id SERIAL, group_no smallint, subgroup_no smallint, spe...
Python
#!/usr/bin/python2 # -*- coding: cp1251 -*- import re import urllib import db_oper def parse_schedule(): schedule_db = [] #расписание - schedule[курс][день][№ группы на курсе] dates = [] #даты дней недели group_db = [] #группы - group_db[курс][группа] - (кол-во подгрупп, номер группы) n = i = 0 for num in ['one'...
Python
#!/usr/bin/python2 # -*- coding: cp1251 -*- import re import urllib import db_oper def parse_schedule(): schedule_db = [] #расписание - schedule[курс][день][№ группы на курсе] dates = [] #даты дней недели group_db = [] #группы - group_db[курс][группа] - (кол-во подгрупп, номер группы) n = i = 0 for num in ['one'...
Python
#!/usr/bin/python2 # -*- coding: utf-8 -*- import sys,os,xmpp,time,select,string,re import db_oper class Bot: def __init__(self,jabber): self.jabber = jabber # self.remotejid = remotejid def register_handlers(self): self.jabber.RegisterHandler('message',self.xmpp_message) self...
Python
# This is Python example on how to use Mongoose embeddable web server, # http://code.google.com/p/mongoose # # Before using the mongoose module, make sure that Mongoose shared library is # built and present in the current (or system library) directory import mongoose import sys # Handle /show and /form URIs. def Even...
Python
# Copyright (c) 2004-2009 Sergey Lyubka # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal # in the Software without restriction, including without limitation the rights # to use, copy, modify, merge, publ...
Python
from composite import CompositeGoal from onek_onek import OneKingAttackOneKingEvaluator, OneKingFleeOneKingEvaluator class Goal_Think(CompositeGoal): def __init__(self, owner): CompositeGoal.__init__(self, owner) self.evaluators = [OneKingAttackOneKingEvaluator(1.0), ...
Python
from goal import Goal class CompositeGoal(Goal): def __init__(self, owner): Goal.__init__(self, owner) self.subgoals = [] def removeAllSubgoals(self): for s in self.subgoals: s.terminate() self.subgoals = [] def processSubgoals(self): # rem...
Python
import unittest import checkers import games from globalconst import * # (white) # 45 46 47 48 # 39 40 41 42 # 34 35 36 37 # 28 29 30 31 # 23 24 25 26 # 17 18 19 20 # 12 13 14 15 # 6 7 8 9 # (bl...
Python
import utils class Observer(object): def update(self, change): utils.abstract()
Python
import re import sys class LinkRules(object): """Rules for recognizing external links.""" # For the link targets: proto = r'http|https|ftp|nntp|news|mailto|telnet|file|irc' extern = r'(?P<extern_addr>(?P<extern_proto>%s):.*)' % proto interwiki = r''' (?P<inter_wiki> [A-Z][a-zA-Z]+ ) :...
Python
from Tkinter import * class AutoScrollbar(Scrollbar): def __init__(self, master=None, cnf={}, **kw): self.container = kw.pop('container', None) self.row = kw.pop('row', 0) self.column = kw.pop('column', 0) self.sticky = kw.pop('sticky', '') Scrollbar.__init__(self, m...
Python
import games import copy import multiprocessing import time import random from controller import Controller from transpositiontable import TranspositionTable from globalconst import * class AlphaBetaController(Controller): def __init__(self, **props): self._model = props['model'] self._...
Python
from goal import Goal from composite import CompositeGoal class Goal_OneKingAttack(CompositeGoal): def __init__(self, owner): CompositeGoal.__init__(self, owner) def activate(self): self.status = self.ACTIVE self.removeAllSubgoals() # because goals are *pushed* onto t...
Python
import math, os, sys from ConfigParser import RawConfigParser DEFAULT_SIZE = 400 BOARD_SIZE = 8 CHECKER_SIZE = 30 MAX_VALID_SQ = 32 MOVE = 0 JUMP = 1 OCCUPIED = 0 BLACK = 1 WHITE = 2 MAN = 4 KING = 8 FREE = 16 COLORS = BLACK | WHITE TYPES = OCCUPIED | BLACK | WHITE | MAN | KING | FREE HUMAN = 0 ...
Python
import os from Tkinter import * from Tkconstants import END, N, S, E, W from command import * from observer import * from globalconst import * from autoscrollbar import AutoScrollbar from textserialize import Serializer from hyperlinkmgr import HyperlinkManager from tkFileDialog import askopenfilename from tk...
Python
import sys import games from globalconst import * class Player(object): def __init__(self, color): self.col = color def _get_color(self): return self.col color = property(_get_color, doc="Player color") class AlphabetaPlayer(Player): def __init__(self, color, depth=4): ...
Python
from UserDict import UserDict class TranspositionTable (UserDict): def __init__ (self, maxSize): UserDict.__init__(self) assert maxSize > 0 self.maxSize = maxSize self.krono = [] self.maxdepth = 0 self.killer1 = [-1]*20 self.killer2 = [-1]*20 self.ha...
Python
import re import sys from rules import Rules from document import DocNode class Parser(object): """ Parse the raw text and create a document object that can be converted into output using Emitter. A separate instance should be created for parsing a new document. The first parameter is the raw tex...
Python
from Tkinter import * from ttk import Combobox, Label from tkFont import families from tkSimpleDialog import Dialog class PreferencesDialog(Dialog): def __init__(self, parent, title, font, size): self._master = parent self.result = False self.font = font self.size = size ...
Python
from Tkinter import PhotoImage from Tkconstants import * from globalconst import BULLET_IMAGE from creoleparser import Parser from rules import LinkRules class TextTagEmitter(object): """ Generate tagged output compatible with the Tkinter Text widget """ def __init__(self, root, txtWidget, hy...
Python
import os from Tkinter import * from Tkconstants import W, E import Tkinter as tk from tkMessageBox import askyesnocancel from multiprocessing import freeze_support from globalconst import * from aboutbox import AboutBox from setupboard import SetupBoard from gamemanager import GameManager from centeredwindow...
Python
from globalconst import BLACK, WHITE, MAN, KING from goalevaluator import GoalEvaluator from onekingattack import Goal_OneKingAttack class OneKingAttackOneKingEvaluator(GoalEvaluator): def __init__(self, bias): GoalEvaluator.__init__(self, bias) def calculateDesirability(self, board): ...
Python
from Tkinter import * class CenteredWindow: def __init__(self, root): self.root = root self.root.after_idle(self.center_on_screen) self.root.update() def center_on_screen(self): self.root.update_idletasks() sw = self.root.winfo_screenwidth() sh = self...
Python
import sys from goal import Goal from composite import CompositeGoal class Goal_OneKingFlee(CompositeGoal): def __init__(self, owner): CompositeGoal.__init__(self, owner) def activate(self): self.status = self.ACTIVE self.removeAllSubgoals() # because goals are *push...
Python
"""Provide some widely useful utilities. Safe for "from utils import *".""" from __future__ import generators import operator, math, random, copy, sys, os.path, bisect #______________________________________________________________________________ # Simple Data Structures: booleans, infinity, Dict, Struct in...
Python
import games import time from move import Move from globalconst import BLACK, WHITE, KING, MAN, OCCUPIED, BLACK_CHAR, WHITE_CHAR from globalconst import BLACK_KING, WHITE_KING, FREE, OCCUPIED_CHAR, FREE_CHAR from globalconst import COLORS, TYPES, TURN, CRAMP, BRV, KEV, KCV, MEV, MCV from globalconst import INTACT...
Python
from Tkinter import * from Tkconstants import W, E, N, S from tkFileDialog import askopenfilename, asksaveasfilename from tkMessageBox import askyesnocancel, showerror from globalconst import * from checkers import Checkers from boardview import BoardView from playercontroller import PlayerController from alpha...
Python
class Move(object): def __init__(self, squares, annotation=''): self.affected_squares = squares self.annotation = annotation def __repr__(self): return str(self.affected_squares)
Python
"""Games, or Adversarial Search. (Chapters 6) """ from utils import infinity, argmax, argmax_random_tie, num_or_str, Dict, update from utils import if_, Struct import random import time #______________________________________________________________________________ # Minimax Search def minimax_decision(state, game)...
Python
from Tkinter import * from tkSimpleDialog import Dialog from globalconst import * class AboutBox(Dialog): def body(self, master): self.canvas = Canvas(self, width=300, height=275) self.canvas.pack(side=TOP, fill=BOTH, expand=0) self.canvas.create_text(152,47,text='Raven', fill='blac...
Python
import copy, textwrap from globalconst import * from move import Move from checkers import Checkers class SavedGame(object): def __init__(self): self._model = Checkers() self.to_move = None self.moves = [] self.description = '' self.black_men = [] self.wh...
Python
from Tkinter import Widget from controller import Controller from globalconst import * class PlayerController(Controller): def __init__(self, **props): self._model = props['model'] self._view = props['view'] self._before_turn_event = None self._end_turn_event = props['end_t...
Python
from abc import ABCMeta, abstractmethod class GoalEvaluator(object): __metaclass__ = ABCMeta def __init__(self, bias): self.bias = bias @abstractmethod def calculateDesirability(self, board): pass @abstractmethod def setGoal(self, board): pass ...
Python
from Tkinter import * from time import time, localtime, strftime class ToolTip( Toplevel ): """ Provides a ToolTip widget for Tkinter. To apply a ToolTip to any Tkinter widget, simply pass the widget to the ToolTip constructor """ def __init__( self, wdgt, msg=None, msgFunc=None, delay=1, foll...
Python
class Command(object): def __init__(self, **props): self.add = props.get('add') or [] self.remove = props.get('remove') or []
Python
from globalconst import BLACK, WHITE, KING import checkers class Operator(object): pass class OneKingAttackOneKing(Operator): def precondition(self, board): plr_color = board.to_move opp_color = board.enemy return (board.count(plr_color) == 1 and board.count(opp_color) == 1 a...
Python
class Controller(object): def stop_process(self): pass
Python
from abc import ABCMeta, abstractmethod class Goal: __metaclass__ = ABCMeta INACTIVE = 0 ACTIVE = 1 COMPLETED = 2 FAILED = 3 def __init__(self, owner): self.owner = owner self.status = self.INACTIVE @abstractmethod def activate(self): pass ...
Python
from Tkinter import * from ttk import Checkbutton from tkSimpleDialog import Dialog from globalconst import * class SetupBoard(Dialog): def __init__(self, parent, title, gameManager): self._master = parent self._manager = gameManager self._load_entry_box_vars() self.result...
Python
from Tkinter import * class HyperlinkManager(object): def __init__(self, textWidget, linkFunc): self.txt = textWidget self.linkfunc = linkFunc self.txt.tag_config('hyper', foreground='blue', underline=1) self.txt.tag_bind('hyper', '<Enter>', self._enter) self.txt.tag...
Python
class DocNode(object): """ A node in the document. """ def __init__(self, kind='', parent=None, content=None): self.children = [] self.parent = parent self.kind = kind self.content = content if self.parent is not None: self.parent.children.append(self...
Python
import urllib2, re, Image, shutil, stat, os, random from urllib import FancyURLopener border = 5 bigw = 1920 bigh = 1200 class AgentOpener(FancyURLopener): version = 'Mozilla/5.0 (Windows; U; Windows NT 5.1; it; rv:1.8.1.11) Gecko/20071127 Firefox/2.0.0.11' agent_opener = AgentOpener() def getImages(file): data ...
Python
#!/usr/bin/env python import os import sys import string import re import StringIO import copy AVOF_name = [ "name", "long_name", "mime_type", "extensions", "priv_data_size", "audio_codec", "video_codec", "write_header", "write_packet", "write_trailer", "flags", "set_parameters", "interleave_packe...
Python
#!/usr/bin/env python import os import sys import string import re import StringIO import copy AVOF_name = [ "name", "long_name", "mime_type", "extensions", "priv_data_size", "audio_codec", "video_codec", "write_header", "write_packet", "write_trailer", "flags", "set_parameters", "interleave_packe...
Python
import webapp2 from google.appengine.ext.webapp import util from google.appengine.ext import db from google.appengine.api import memcache import dbmodels import os import json import datetime import calgen import math import logging import time import pickle from utilities import * import views from google.appengine.ex...
Python
import webapp2 from google.appengine.ext import db import dbmodels import os from utilities import * import views import logging from google.appengine.ext.webapp import template import logging class Show(webapp2.RequestHandler): def get(self): v = TemplateValues() v.pageinfo = TemplateValues() ...
Python
countries= [ "United States", "United Kingdom", "Afghanistan", "Albania", "Algeria", "American Samoa", "Andorra", "Angola", "Anguilla", "Antarctica", "Antigua and Barbuda", "Argentina", "Armenia", "Aruba", "Australia", "Austria", "Azerbaijan", "Bahamas", "Bahrain", "Bangladesh", "Barbados", "Belarus", "Belgium", "Beliz...
Python
from google.appengine.ext import db import calendar import datetime from dbmodels import Assignment, Site import logging class Month(): names = [ "January","February","March","April","May","June", "July","August","September","October","November","December"] def __init__(self, year, month, request...
Python
#from google.appengine.ext import webapp import webapp2 from google.appengine.ext.webapp import util from google.appengine.ext import db import dbmodels import os import datetime from utilities import * import views import json import logging from google.appengine.ext.webapp import template from dateutil.relativedelta ...
Python
#!/usr/bin/env python # # Copyright 2007 Google 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 o...
Python
#from google.appengine.ext import webapp import webapp2 from google.appengine.ext.webapp import util from google.appengine.ext import db from google.appengine.api import memcache import dbmodels import os import datetime import logging from utilities import * import views from google.appengine.ext.webapp import templa...
Python
import datetime from google.appengine.ext import db from google.appengine.datastore import entity_pb from google.appengine.api import users from google.appengine.api import memcache import logging import webapp2 class Calendar(db.Model): data = db.BlobProperty() timestamp = db.DateTimeProperty() manual = d...
Python
#from google.appengine.ext import webapp import webapp2 from google.appengine.ext.webapp import util from google.appengine.ext import db import dbmodels import os import datetime from utilities import * import views from google.appengine.ext.webapp import template class Show(webapp2.RequestHandler): def get(self)...
Python
from google.appengine.ext import db import calendar import datetime from dbmodels import Assignment, Site import logging import webapp2 class Run(webapp2.RequestHandler): def get(self): num_months = 3 now = datetime.datetime.now() assignment_query = Assignment.get_all() assignment...
Python
import reportlab from reportlab.lib.pagesizes import A4, letter from reportlab.lib.units import mm, inch from reportlab.rl_config import defaultPageSize from reportlab.platypus import SimpleDocTemplate, Paragraph, Spacer, Table, TableStyle, Image from reportlab.lib.styles import getSampleStyleSheet, ParagraphStyle from...
Python
import datetime from google.appengine.api import users class TemplateValues(object): def __init__(self): self.user = users.get_current_user() self.logout_url = users.create_logout_url("/") self.login_url = users.create_login_url("/") def expdate(): delta = datetime.timedelta(days=7) ...
Python
from google.appengine.ext import db import calendar import datetime from dbmodels import Assignment, Calendar, NewAssignment import logging import webapp2 import pickle def assignmentDict(model): pass class Run(webapp2.RequestHandler): def get(self): manual = self.request.get("manual") == "1" ...
Python
#
Python
#from google.appengine.ext import webapp import webapp2 from google.appengine.ext.webapp import util from google.appengine.ext import db from google.appengine.api import memcache import dbmodels import os import datetime from utilities import * import views from google.appengine.ext.webapp import template import loggi...
Python
#from google.appengine.ext import webapp import webapp2 from google.appengine.ext.webapp import util from google.appengine.ext import ndb from google.appengine.api import memcache import dbmodels import os import datetime from utilities import * import views import json import logging from google.appengine.ext.webapp i...
Python
import os views = "views" main = os.path.join(views, "main.html") assignments = os.path.join(views,"assignments.html") assignmentForm = os.path.join("assignmentForm.html") partners = "partners.html" partnerForm = "partnerForm.html" projects = "projects.html" projectForm = "projectForm.html" sites = "sites.html" site...
Python
from google.appengine.ext import webapp import webapp2 import dbmodels class Api(webapp2.RequestHandler): def get(self, arg): self.response.write(arg)
Python
""" Copyright (c) 2003-2007 Gustavo Niemeyer <gustavo@niemeyer.net> This module offers extensions to the standard python 2.3+ datetime module. """ __author__ = "Gustavo Niemeyer <gustavo@niemeyer.net>" __license__ = "PSF License" import datetime import struct import time import sys import os relativedelta = None pa...
Python
""" Copyright (c) 2003-2010 Gustavo Niemeyer <gustavo@niemeyer.net> This module offers extensions to the standard python 2.3+ datetime module. """ __author__ = "Gustavo Niemeyer <gustavo@niemeyer.net>" __license__ = "PSF License" import itertools import datetime import calendar import thread import sys __all__ = ["...
Python
""" Copyright (c) 2003-2005 Gustavo Niemeyer <gustavo@niemeyer.net> This module offers extensions to the standard python 2.3+ datetime module. """ from dateutil.tz import tzfile from tarfile import TarFile import os __author__ = "Gustavo Niemeyer <gustavo@niemeyer.net>" __license__ = "PSF License" __all__ = ["setca...
Python
""" Copyright (c) 2003-2010 Gustavo Niemeyer <gustavo@niemeyer.net> This module offers extensions to the standard python 2.3+ datetime module. """ __author__ = "Gustavo Niemeyer <gustavo@niemeyer.net>" __license__ = "PSF License" import datetime import calendar __all__ = ["relativedelta", "MO", "TU", "WE", "TH", "F...
Python
# This code was originally contributed by Jeffrey Harris. import datetime import struct import _winreg __author__ = "Jeffrey Harris & Gustavo Niemeyer <gustavo@niemeyer.net>" __all__ = ["tzwin", "tzwinlocal"] ONEWEEK = datetime.timedelta(7) TZKEYNAMENT = r"SOFTWARE\Microsoft\Windows NT\CurrentVersion\Time Zones" TZ...
Python
""" Copyright (c) 2003-2010 Gustavo Niemeyer <gustavo@niemeyer.net> This module offers extensions to the standard python 2.3+ datetime module. """ __author__ = "Gustavo Niemeyer <gustavo@niemeyer.net>" __license__ = "PSF License" __version__ = "1.5"
Python
""" Copyright (c) 2003-2007 Gustavo Niemeyer <gustavo@niemeyer.net> This module offers extensions to the standard python 2.3+ datetime module. """ __author__ = "Gustavo Niemeyer <gustavo@niemeyer.net>" __license__ = "PSF License" import datetime __all__ = ["easter", "EASTER_JULIAN", "EASTER_ORTHODOX", "EASTER_WESTE...
Python
#!/usr/bin/env pypy import os, sys, logging, re import argparse import fnmatch configurations = {'lite', 'pro'} package_dirs = { 'lite': ('src/cx/hell/android/pdfview',), 'pro': ('src/cx/hell/android/pdfviewpro',) } file_replaces = { 'lite': ( 'cx.hell.android.pdfview.', '"cx.hell.an...
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
#!/usr/bin/env python import codecs import re import jinja2 import markdown def process_slides(): with codecs.open('../../presentation-output.html', 'w', encoding='utf8') as outfile: md = codecs.open('slides.md', encoding='utf8').read() md_slides = md.split('\n---\n') print 'Compiled %s slides.' % len(m...
Python