code
stringlengths
1
1.72M
language
stringclasses
1 value
import time import ptxcb import config from command import Command from window import Window from monitor import Monitor from workspace import Workspace from container import Container _ACTIVE = None pointer_grab = False moving = False properties = {} xinerama = ptxcb.connection.xinerama_get_screens() def init(): ...
Python
# Library imports import config import ptxcb import tilers # Class imports from workspace import Workspace class Monitor(object): @staticmethod def add(wsid, xinerama): for mid, screen in enumerate(xinerama): new_mon = Monitor( Workspace.WORKSPACES[wsid], mi...
Python
import ConfigParser import distutils.sysconfig import os import os.path import pwd import re import shutil import sys # This is PyTyle's custom configuration parser. There are two main # goals accomplished with this sub-class: # # 1. It allows retrival of some other types, like lists, booleans, and # lists of certa...
Python
events = { 'KeyPressEvent': 2, 'KeyReleaseEvent': 3, 'ButtonPressEvent': 4, 'ButtonReleaseEvent': 5, 'MotionNotifyEvent': 6, 'EnterNotifyEvent': 7, 'LeaveNotifyEvent': 8, 'FocusInEvent': 9, 'FocusOutEvent': 10, 'KeymapNotifyEvent': 11, 'ExposeEvent': 12, 'GraphicsExposure...
Python
import xcb.xproto from window import Window from window import XROOT from atom import Atom def dispatch(e): NotifyModes = { 0: 'Normal', 1: 'Grab', 2: 'Ungrab', 3: 'WhileGrabbed' } NotifyDetails = { 0: 'Ancestor', 1: 'Virtual', 2: 'Inferior', 3: 'Nonlinear', 4: 'NonlinearVirtual',...
Python
import struct import xcb.xproto, xcb.xcb, xcb.xinerama, xcb.randr conn = None setup = None syms_to_codes = {} codes_to_syms = {} def init(): global conn, setup conn = xcb.xcb.connect() setup = conn.get_setup() init_keymap() def init_keymap(): global setup, syms_to_codes, codes_to_syms q ...
Python
atoms = { '_PYTYLE_TYPE': ('ATOM', 32), '_PYTYLE_TYPE_PLACE_HOLDER': ('ATOM', 32), '_PYTYLE_TYPE_BORDER': ('ATOM', 32), 'WM_CLASS': ('STRING', 8), 'WM_HINTS': ('WM_HINTS', 32), 'WM_NAME': ('STRING', 8), 'WM_NORMAL_HINTS': ('WM_SIZE_HINTS', 32), 'WM_PROTOCOLS': ('ATOM', 32), 'WM_STAT...
Python
import struct import xcb.xproto import connection from atoms import atoms class Atom: _cache = {} @staticmethod def build_cache(): if Atom._cache: return for atom in atoms: Atom._cache[atom] = connection.get_core().InternAtom( False, ...
Python
import atom import connection import event import keysyms import window Atom = atom.Atom BlankWindow = window.BlankWindow LineWindow = window.LineWindow RootWindow = window.RootWindow Window = window.Window keysyms = keysyms.keysyms atoms = atoms.atoms XROOT = window.XROOT
Python
import struct, traceback, time import xcb.xproto, xcb.xcb import connection from atom import Atom from events import events class Window(object): queue = [] @staticmethod def exec_queue(): for tup in Window.queue: tup[0](*tup[1:]) Window.queue = [] def __init__(self, wid...
Python
keysyms = { 'VoidSymbol': 0xffffff, 'BackSpace': 0xff08, 'Tab': 0xff09, 'Linefeed': 0xff0a, 'Clear': 0xff0b, 'Return': 0xff0d, 'Pause': 0xff13, 'Scroll_Lock': 0xff14, 'Sys_Req': 0xff15, 'Escape': 0xff1b, 'Delete': 0xffff, 'Multi_key': 0xff20, 'Codeinput': 0xff37, ...
Python
import ptxcb import config from window import BogusWindow class Container(object): idinc = 1 active = None @staticmethod def manage_focus(win): if win and win.container: win.container.borders_activate(win.container.tiler.decor) elif Container.active: Container....
Python
import time import ptxcb import config from workspace import Workspace class Window(object): WINDOWS = {} @staticmethod def add(wid): if wid not in Window.WINDOWS: if Window.manageable(wid): win = Window(wid) Window.WINDOWS[wid] = win ...
Python
import time import config import ptxcb import state import tilers from command import Command from window import Window from tile import Tile class Dispatcher(object): def __init__(self, event_data): self._event_data = event_data self._stop = False assert 'event' in self._event_data ...
Python
import xcb.xproto import ptxcb import config class Command: _cmds = {} _mods = { 'alt': xcb.xproto.ModMask._1, 'ctrl': xcb.xproto.ModMask.Control, 'shift': xcb.xproto.ModMask.Shift, 'super': xcb.xproto.ModMask._4, 'menu': xcb.xproto.ModMask._3 } def __init__(se...
Python
from tile import Tile from container import Container class AutoTile(Tile): def __init__(self, monitor): Tile.__init__(self, monitor) self.store = None self.cycle_index = 0 # # Helper methods # def add(self, win): if ( win.tilable() and self.tiling and ...
Python
#!/usr/bin/env python #============================================================================== # PyTyle - An on-demand tiling manager # Copyright (C) 2009-2010 Andrew Gallant <andrew@pytyle.com> # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Publ...
Python
#!/usr/bin/env python ## Copyright (c) 2012 The WebM project authors. All Rights Reserved. ## ## Use of this source code is governed by a BSD-style license ## that can be found in the LICENSE file in the root of the source ## tree. An additional intellectual property rights grant can be found ## in the file PATENT...
Python
#!/usr/bin/env python ## Copyright (c) 2012 The WebM project authors. All Rights Reserved. ## ## Use of this source code is governed by a BSD-style license ## that can be found in the LICENSE file in the root of the source ## tree. An additional intellectual property rights grant can be found ## in the file PATENT...
Python
#!/usr/bin/env python ## Copyright (c) 2012 The WebM project authors. All Rights Reserved. ## ## Use of this source code is governed by a BSD-style license ## that can be found in the LICENSE file in the root of the source ## tree. An additional intellectual property rights grant can be found ## in the file PATENT...
Python
#!/usr/bin/python ## Copyright (c) 2012 The WebM project authors. All Rights Reserved. ## ## Use of this source code is governed by a BSD-style license ## that can be found in the LICENSE file in the root of the source ## tree. An additional intellectual property rights grant can be found ## in the file PATENTS. ...
Python
#!/usr/bin/python import getopt import subprocess import sys LONG_OPTIONS = ["shard=", "shards="] BASE_COMMAND = "./configure --enable-internal-stats --enable-experimental" def RunCommand(command): run = subprocess.Popen(command, shell=True) output = run.communicate() if run.returncode: print "Non-zero ret...
Python
""" * Copyright (c) 2012 The WebM project authors. All Rights Reserved. * * Use of this source code is governed by a BSD-style license * that can be found in the LICENSE file in the root of the source * tree. An additional intellectual property rights grant can be found * in the file PATENTS. All contributi...
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
''' 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
# Django settings for minutes project. import os DEBUG = True TEMPLATE_DEBUG = DEBUG ADMINS = ( # ('Your Name', 'your_email@domain.com'), ) MANAGERS = ADMINS DATABASES = { 'default': { 'ENGINE': 'django.db.backends.postgresql_psycopg2', # Add 'postgresql_psycopg2', 'postgresql', 'mysql', 'sqlite3' o...
Python
"""Update items""" import os, sys, site python_version = 'python%s.%s' % sys.version_info[:2] site_path = os.path.abspath( os.path.normpath( os.path.join(os.path.dirname(__file__), '../lib', python_version, 'site-packages'))) site.addsitedir(site_path) sys.path.append(os.path.abspath...
Python
import persistent_messages from persistent_messages.constants import PERSISTENT_MESSAGE_LEVELS from django.db import models from django.contrib.auth.models import User from django.contrib import messages from django.contrib.messages import utils from django.utils.translation import ugettext_lazy as _ from django.utils...
Python
from persistent_messages.models import Message from persistent_messages.constants import PERSISTENT_MESSAGE_LEVELS from django.contrib import messages from django.contrib.messages.storage.base import BaseStorage from django.contrib.auth.models import AnonymousUser from django.contrib.messages.storage.fallback import F...
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 * urlpatterns = patterns('', url(r'^detail/(?P<message_id>\d+)/$', 'persistent_messages.views.message_detail', name='message_detail'), url(r'^mark_read/(?P<message_id>\d+)/$', 'persistent_messages.views.message_mark_read', name='message_mark_read'), url(r'^mark_closed/...
Python
from django.core.mail import send_mail def email(level, message, extra_tags, subject, user, from_user): if not user or not user.email: raise Exception('Function needs to be passed a `User` object with valid email address.') send_mail(subject, message, from_user.email if from_user else None, [user.email...
Python
DEBUG = 110 INFO = 120 SUCCESS = 125 WARNING = 130 ERROR = 140 DEFAULT_TAGS = { INFO: 'info', SUCCESS: 'success', WARNING: 'warning', ERROR: 'error', } PERSISTENT_MESSAGE_LEVELS = (INFO, SUCCESS, WARNING, ERROR)
Python
from persistent_messages.api import * from persistent_messages.constants import * from django.contrib import messages messages.DEFAULT_TAGS.update(DEFAULT_TAGS)
Python
from persistent_messages.models import Message from persistent_messages.storage import get_user from django.http import HttpResponseRedirect from django.shortcuts import get_object_or_404, render_to_response from django.template import RequestContext from django.core.exceptions import PermissionDenied from mitems.ajax ...
Python
from persistent_messages import notify from persistent_messages import constants def add_message(request, level, message, extra_tags='', fail_silently=False, subject='', user=None, email=False, from_user=None, expires=None, close_timeout=None): """ """ if email: notify.email(level, message, extra_...
Python
from persistent_messages.models import Message from django.contrib import admin class MessageAdmin(admin.ModelAdmin): list_display = ('level', 'user', 'from_user', 'subject', 'message', 'created', 'read', 'closed', 'is_persistent') admin.site.register(Message, MessageAdmin)
Python
"""Social auth models""" import warnings from datetime import timedelta from django.db import models from django.conf import settings from social_auth.fields import JSONField # If User class is overridden, it *must* provide the following fields, # or it won't be playing nicely with django.contrib.auth module: # # ...
Python
import urlparse def sanitize_redirect(host, redirect_to): """ Given the hostname and an untrusted URL to redirect to, this method tests it to make sure it isn't garbage/harmful and returns it, else returns None. See http://code.djangoproject.com/browser/django/trunk/django/contrib/auth/views.py#L...
Python
"""URLs module""" from django.conf.urls.defaults import patterns, url from social_auth.views import auth, complete, associate, associate_complete, \ disconnect urlpatterns = patterns('', url(r'^login/(?P<backend>[^/]+)/$', auth, name='begin'), url(r'^complete/(?P<backend>[^/]+)/...
Python
from django.core.exceptions import ValidationError from django.db import models from django.utils import simplejson class JSONField(models.TextField): """Simple JSON field that stores python structures as JSON strings on database. """ __metaclass__ = models.SubfieldBase def to_python(self, value...
Python
""" Django-social-auth application, allows OpenId or OAuth user registration/authentication just adding a few configurations. """ version = (0, 3, 9) __version__ = '.'.join(map(str, version))
Python
""" Facebook OAuth support. This contribution adds support for Facebook OAuth service. The settings FACEBOOK_APP_ID and FACEBOOK_API_SECRET must be defined with the values given by Facebook application registration process. Extended permissions are supported by defining FACEBOOK_EXTENDED_PERMISSIONS setting, it must ...
Python
""" LiveJournal OpenID support. This contribution adds support for LiveJournal OpenID service in the form username.livejournal.com. Username is retrieved from the identity url. """ import urlparse from social_auth.backends import OpenIDBackend, OpenIdAuth, USERNAME # LiveJournal conf LIVEJOURNAL_URL = 'http://%s.li...
Python
""" Orkut OAuth support. This contribution adds support for Orkut OAuth service. The scope is limited to http://orkut.gmodules.com/social/ by default, but can be extended with ORKUT_EXTRA_SCOPE on project settings. Also name, display name and emails are the default requested user data, but extra values can be specifie...
Python
""" Linkedin OAuth support No extra configurations are needed to make this work. """ import urlparse from xml.etree import ElementTree from social_auth.backends import ConsumerBasedOAuth, OAuthBackend LINKEDIN_SERVER = 'linkedin.com' LINKEDIN_REQUEST_TOKEN_URL = 'https://api.%s/uas/oauth/requestToken' % \ ...
Python
"""Contrib auth modules"""
Python
""" Base backends structures. This module defines base classes needed to define custom OpenID or OAuth auth services from third parties. This customs must subclass an Auth and and Backend class, check current implementation for examples. Also the modules *must* define a BACKENDS dictionary with the backend name (whic...
Python
""" Twitter OAuth support. This adds support for Twitter OAuth service. An application must be registered first on twitter and the settings TWITTER_CONSUMER_KEY and TWITTER_CONSUMER_SECRET must be defined with they corresponding values. User screen name is used to generate username. By default account id is stored i...
Python
""" Yahoo OpenID support No extra configurations are needed to make this work. """ from social_auth.backends import OpenIDBackend, OpenIdAuth YAHOO_OPENID_URL = 'http://yahoo.com' class YahooBackend(OpenIDBackend): """Yahoo OpenID authentication backend""" name = 'yahoo' class YahooAuth(OpenIdAuth): ...
Python
"""Views""" from django.conf import settings from django.http import HttpResponseRedirect, HttpResponse, \ HttpResponseServerError from django.core.urlresolvers import reverse from django.db import transaction from django.contrib.auth import login, REDIRECT_FIELD_NAME from django.contrib.auth.de...
Python
"""OpenId storage that saves to django models""" import time import base64 from openid.association import Association as OIDAssociation from openid.store.interface import OpenIDStore from openid.store.nonce import SKEW from social_auth.models import Association, Nonce class DjangoOpenIDStore(OpenIDStore): """St...
Python
"""Admin settings""" from django.contrib import admin from social_auth.models import UserSocialAuth, Nonce, Association class UserSocialAuthOption(admin.ModelAdmin): """Social Auth user options""" list_display = ('id', 'user', 'provider', 'uid') search_fields = ('user__name',) list_filter = ('provide...
Python
"""Signals""" from django.dispatch import Signal # Pre save signal # This signal is sent when user instance is about to be updated with # new values from services provided. This way custom actions can be # attached and values updated if needed before the saving time. # # Handlers must return True if any value ...
Python
"""Update items""" import os, sys, site python_version = 'python%s.%s' % sys.version_info[:2] site_path = os.path.abspath( os.path.normpath( os.path.join(os.path.dirname(__file__), '../lib', python_version, 'site-packages'))) site.addsitedir(site_path) sys.path.append(os.path.abspath...
Python
from django.conf.urls.defaults import * from mitems import views as mitems_views from mitems import ajax as ajax_views from django.conf import settings from django.contrib.staticfiles.urls import staticfiles_urlpatterns from django.conf.urls.static import static from django.views.generic.simple import direct_to_templat...
Python
"""Update items""" import os, sys, site python_version = 'python%s.%s' % sys.version_info[:2] site_path = os.path.abspath( os.path.normpath( os.path.join(os.path.dirname(__file__), '../lib', python_version, 'site-packages'))) site.addsitedir(site_path) sys.path.append(os.path.abspath...
Python
from django.db.models.signals import class_prepared def longer_email_username(sender, *args, **kwargs): # You can't just do `if sender == django.contrib.auth.models.User` # because you would have to import the model # You have to test using __name__ and __module__ if (sender.__name__ in ("User", "UserP...
Python
# coding=utf-8 from shorturls.baseconv import base62 from django.contrib.auth.models import User from django.core.exceptions import ObjectDoesNotExist from django.db import models from django.core.cache import cache from django_autoslug.fields import AutoSlugField from django.template.defaultfilters import slugify fro...
Python
import os from random import Random import uuid from django.http import HttpResponse from django.utils import simplejson from django.conf import settings import twitter import urllib2, urllib import string import gdata.oauth import gdata.contacts.data import gdata.contacts.client from PIL import Image import logging tr...
Python
import gdata.gauth import gdata.contacts.client from django.http import HttpResponseRedirect CONSUMER_KEY = 'take.8minut.es' CONSUMER_SECRET = 'w1usAxob4zjpZUzsyMTwQio_' SCOPES = ['https://www.google.com/m8/feeds/'] oauth_callback_url = 'http://8minutes.trezor.by/get_access_token/' def get_request_token(request): ...
Python
# -*- coding: utf8 import mailbox import lxml.html from lxml.html.clean import Cleaner import os from email.Header import decode_header from email.utils import parseaddr from django.conf import settings from django.utils.encoding import force_unicode from mitems.models import Item_category, Item, UserProfile, ItemIma...
Python
# coding=utf-8 """Tweet items""" from datetime import timedelta, datetime from mitems.tools.utils import post_to_twitter, TWITTER_MAX_LENGTH, TwitterError from django.conf import settings from mitems.tools.logs import Log from mitems.models import Item log = Log(settings.TWITTER_LOG_FILE, settings.TWITTER_LOG_LOGGER,...
Python
# coding=utf-8 from datetime import datetime, timedelta from django.conf import settings from django.db.models import Q from django.utils.safestring import mark_safe from django.core.mail import send_mail from django.template import Context, Template from urllib import basejoin import persistent_messages from persisten...
Python
# -*- coding: utf8 import sys, logging, logging.handlers class Log(object): """Logger class""" def __init__(self, log_file, logger_name, maxb, count, debug): try: fmt = '%(asctime)s: %(name)s: %(levelname)s: %(message)s' datefmt = '%a, %d %b %Y %H:%M:%S' self.lo...
Python
# coding=utf-8 """Parse reuters feed and save in database with random user as owner""" from datetime import timedelta, datetime import feedparser import urllib from django.conf import settings from django.db.models.fields import BooleanField import lxml.html from lxml.html.clean import clean_html import os from geopy ...
Python
from datetime import datetime, timedelta import smtplib from django.db.utils import IntegrityError from django.http import HttpResponse from django.conf import settings from django.template.loader import render_to_string from django.template import RequestContext from django.utils import simplejson from django.db impor...
Python
from django.conf import settings from django.db.models.fields.files import ImageFieldFile from django.forms import ModelForm from django.forms.widgets import TextInput, Textarea, FileInput, Select from mitems.models import Item, Comment, Like, CommentLike, Airtime,\ Share, Follower, UserProfile, Notification, Inque...
Python
""" This file demonstrates writing tests using the unittest module. These will pass when you run "manage.py test". Replace this with more appropriate tests for your application. """ from django.test import TestCase class SimpleTest(TestCase): def test_basic_addition(self): """ Tests that 1 + 1 a...
Python
from django import template register = template.Library() @register.filter_function def order_by(queryset, args): args = [x.strip() for x in args.split(',')] return queryset.order_by(*args) @register.filter_function def reverse(queryset): return queryset.reverse() @register.filter_function def call(obj...
Python
from django.conf import settings from django.template.loader import render_to_string def analytics(request): """ Returns analytics code. """ if getattr(settings, 'GOOGLE_ANALYTICS_KEY', None): return dict( analytics_code=render_to_string("google_analytics.html", ...
Python
from datetime import datetime, timedelta, date from django.contrib.auth.decorators import login_required from django.shortcuts import render from django.http import Http404, HttpResponseRedirect from django.conf import settings from mitems.models import Item, ItemImage, UserProfile, Notification from mitems.forms impo...
Python
from facegraph.django.middleware import FacebookGraphMiddleware from django.utils import simplejson as json from django.contrib import messages from django.core.urlresolvers import reverse class GraphMiddleware(FacebookGraphMiddleware): def access_token(self, request): try: return request.user...
Python
from django.contrib import admin from django.contrib.sites.models import Site from mitems.models import UserProfile, Item, Item_category,\ Item_group, Item_type, Comment, Like, Share, Follower,\ ItemImage, Airtime, Inquestion, Notification from persistent_messages.models import Message from django.contrib.auth.models i...
Python
import re import datetime from django.template.defaultfilters import slugify from django.db.models import SlugField, SubfieldBase from south.modelsinspector import add_introspection_rules class AutoSlugField(SlugField): """ AutoSlugField By default, sets editable=False, blank=True. Required arguments: ...
Python
"""Update items""" import os, sys, site python_version = 'python%s.%s' % sys.version_info[:2] site_path = os.path.abspath( os.path.normpath( os.path.join(os.path.dirname(__file__), '../lib', python_version, 'site-packages'))) site.addsitedir(site_path) sys.path.append(os.path.abspath...
Python
"""Update items""" import os, sys, site python_version = 'python%s.%s' % sys.version_info[:2] site_path = os.path.abspath( os.path.normpath( os.path.join(os.path.dirname(__file__), '../lib', python_version, 'site-packages'))) site.addsitedir(site_path) sys.path.append(os.path.abspath...
Python
"""Update items""" import os, sys, site python_version = 'python%s.%s' % sys.version_info[:2] site_path = os.path.abspath( os.path.normpath( os.path.join(os.path.dirname(__file__), '../lib', python_version, 'site-packages'))) site.addsitedir(site_path) sys.path.append(os.path.abspath...
Python
import sys, os sys.path.append(os.path.abspath(os.path.join(os.path.dirname(__file__), '../'))) sys.path.append(os.path.abspath(os.path.dirname(__file__))) os.environ['DJANGO_SETTINGS_MODULE'] = 'settings' import django.core.handlers.wsgi application = django.core.handlers.wsgi.WSGIHandler()
Python
"""Update items""" import os, sys, site python_version = 'python%s.%s' % sys.version_info[:2] site_path = os.path.abspath( os.path.normpath( os.path.join(os.path.dirname(__file__), '../lib', python_version, 'site-packages'))) site.addsitedir(site_path) sys.path.append(os.path.abspath...
Python
#!/usr/bin/env python2 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
#!/usr/bin/python2.6 # # Simple http server to emulate api.playfoursquare.com import logging import shutil import sys import urlparse import SimpleHTTPServer import BaseHTTPServer class RequestHandler(BaseHTTPServer.BaseHTTPRequestHandler): """Handle playfoursquare.com requests, for testing.""" def do_GET(self...
Python
#!/usr/bin/python import os import subprocess import sys BASEDIR = '../main/src/com/joelapenna/foursquare' TYPESDIR = '../captures/types/v1' captures = sys.argv[1:] if not captures: captures = os.listdir(TYPESDIR) for f in captures: basename = f.split('.')[0] javaname = ''.join([c.capitalize() for c in basena...
Python
#!/usr/bin/python """ Pull a oAuth protected page from foursquare. Expects ~/.oget to contain (one on each line): CONSUMER_KEY CONSUMER_KEY_SECRET USERNAME PASSWORD Don't forget to chmod 600 the file! """ import httplib import os import re import sys import urllib import urllib2 import urlparse import user from xml....
Python
#!/usr/bin/python import datetime import sys import textwrap import common from xml.dom import pulldom PARSER = """\ /** * Copyright 2009 Joe LaPenna */ package com.joelapenna.foursquare.parsers; import com.joelapenna.foursquare.Foursquare; import com.joelapenna.foursquare.error.FoursquareError; import com.joel...
Python
#!/usr/bin/python import logging from xml.dom import minidom from xml.dom import pulldom BOOLEAN = "boolean" STRING = "String" GROUP = "Group" # Interfaces that all FoursquareTypes implement. DEFAULT_INTERFACES = ['FoursquareType'] # Interfaces that specific FoursqureTypes implement. INTERFACES = { } DEFAULT_CLA...
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
#!/usr/bin/python2.6 # # Simple http server to emulate api.playfoursquare.com import logging import shutil import sys import urlparse import SimpleHTTPServer import BaseHTTPServer class RequestHandler(BaseHTTPServer.BaseHTTPRequestHandler): """Handle playfoursquare.com requests, for testing.""" def do_GET(self...
Python
#!/usr/bin/python import datetime import sys import textwrap import common from xml.dom import pulldom PARSER = """\ /** * Copyright 2009 Joe LaPenna */ package com.joelapenna.foursquare.parsers; import com.joelapenna.foursquare.Foursquare; import com.joelapenna.foursquare.error.FoursquareError; import com.joel...
Python
#!/usr/bin/python """ Pull a oAuth protected page from foursquare. Expects ~/.oget to contain (one on each line): CONSUMER_KEY CONSUMER_KEY_SECRET USERNAME PASSWORD Don't forget to chmod 600 the file! """ import httplib import os import re import sys import urllib import urllib2 import urlparse import user from xml....
Python