code
stringlengths
1
1.72M
language
stringclasses
1 value
""" 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('pinkewang.share.views', )
Python
# Create your views here.
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
#!/usr/bin/env python #coding:utf-8 import web import memcache from web.contrib.template import render_mako #数据库配置 db = web.database(dbn = 'mysql', db = 'davidblog', user='root', pw = 'root') #memcache配置 mc = memcache.Client(['127.0.0.1:11211'], debug=0) #render_mako配置 render = render_mako( directories = ['...
Python
#coding=utf-8 from web import form username_validate = form.regexp(r".{3,15}$", u"请输入3-15位的用户名") email_validate = form.regexp(r".*@.*", u"请输入合法的Email地址") url_validate = form.regexp(r"http://.*", u"请输入合法的URL地址") commentForm = form.Form( form.Textbox('name', form.notnull, username_validate), form.Textb...
Python
#!/usr/bin/env python #coding:utf-8 import web import memcache from web.contrib.template import render_mako #数据库配置 db = web.database(dbn = 'mysql', db = 'davidblog', user='root', pw = 'root') #memcache配置 mc = memcache.Client(['127.0.0.1:11211'], debug=0) #render_mako配置 render = render_mako( directories = ['...
Python
#!/usr/bin/env python2.6 #coding:utf-8 import web from settings import render_mako import views urls = ( '/', 'views.index', '/entry/(.*)/', 'views.entry', '/category/(.*)/', 'views.category', '/tag/(.*)/', 'views.tag', '/add_comment/', 'views.addComment', ...
Python
from settings import mc import pickle class MCache(object): def set(self, name, value): return mc.set(name, pickle.dumps(value)) def get(self, name): value = mc.get(name) if value is not None: return pickle.loads(value) return None def delete(self, name): ...
Python
#!/usr/bin/env python2.6 #coding:utf-8 import web from settings import render_mako import views urls = ( '/', 'views.index', '/entry/(.*)/', 'views.entry', '/category/(.*)/', 'views.category', '/tag/(.*)/', 'views.tag', '/add_comment/', 'views.addComment', ...
Python
#coding:utf-8 import web from davidblog import render from forms import commentForm from datetime import datetime from settings import db, render from cache import mcache def getCategories(): categories = mcache.get('categories') if categories is None: categories = list(db.query('SELECT * FROM categor...
Python
#!/usr/bin/env python import sys from distutils.core import setup required = [] setup( name='google-docs-fs', version='1.0rc2', description='Treat Google Docs as a local file system', author='Scott Walton', author_email='d38dm8nw81k1ng@gmail.com', license='GPLv2', url='http://code.google....
Python
#!/usr/bin/env python import sys import os sys.path.insert(0, os.path.dirname(os.path.abspath(__file__))) from googledocsfs import gFile gFile.main()
Python
#!/usr/bin/env python # # gNet.py # # Copyright 2009 Scott C. Walton <d38dm8nw81k1ng@gmail.com> # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License (version 2), as # published by the Free Software Foundation # # This program is dist...
Python
#!/usr/bin/env python # -*- coding: utf-8 -*- # # gFile.py # # Copyright 2008-2009 Scott C. Walton <d38dm8nw81k1ng@gmail.com> # truncate() function written by miGlanz@gmail.com # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License (vers...
Python
#!/usr/bin/env python import time class StopWatch(object): """A small object to simulate a typical stopwatch.""" def __init__(self): self.restart() def __str__(self): return str(time.time()-self.start) def restart(self): self.start = time.time()
Python
#!/usr/bin/env python try: import argparse except ImportError: import zipfile import urllib2 import os # A non-seekable stream doesn't suffice, downloading open('argparse.zip', 'wb').write(urllib2.urlopen( 'http://argparse.googlecode.com/files/argparse-1.1.zip' ).read()) # Ext...
Python
#!/usr/bin/env python from itertools import count, izip, dropwhile from collections import deque from operator import itemgetter from bisect import bisect_left import sys import os import time import cPickle import numpy as np # additional modules from vrptw import * from vrptw.consts import * from compat import * ...
Python
#!/usr/bin/env python # may perhaps even work on systems without numpy try: import numpy except: numpy = type('dummy', (object,), dict(float64=float))() from vrptw import VrptwTask class DummyTask(VrptwTask): def __init__(self, cust = [ [0, 0, 0, 0, 0, 20, 0], [1, 1, 1, 20, 1, 5, ...
Python
from distutils.core import setup from glob import glob setup(name='Pygrout', version='0.1', description='VRPTW solving utility', author='Tomasz Gandor', url='http://code.google.com/p/pygrout/', packages=['vrptw', 'solomons', 'hombergers'], package_data = { 'vrptw': ['bestknown/*.txt...
Python
from random import Random from operator import itemgetter import time import cPickle import os import sys import numpy as np from undo import UndoStack from consts import * u = UndoStack() """Global undo - may be later made possible to override.""" r = Random() """The random number generator for the optimization."...
Python
# tuple indices in customer tuple: # number, coordinates(X,Y), demand, ready(A), due(B), service time ID, X, Y, DEM, A, B, SRV = range(7) # list indices in route list structure: # route len (num edges), capacity, total distance, edge list R_LEN, R_CAP, R_DIS, R_EDG = range(4) # list indices in edge list structure (in...
Python
#!/usr/bin/env python import sys import pstats import os def main(): if len(sys.argv) == 1: print "\nUsage: %s profile_output [sort_order] [profile_output...]" % sys.argv[0] print """ Where sort order may be: time (default), cumulative, ... (taken from documentation:) Vali...
Python
# -*- coding: utf-8 -*- # Form implementation generated from reading ui file 'helper.ui' # # Created: Mon Aug 29 16:54:25 2011 # by: PyQt4 UI code generator 4.8.3 # # WARNING! All changes made in this file will be lost! from PyQt4 import QtCore, QtGui try: _fromUtf8 = QtCore.QString.fromUtf8 except Attribut...
Python
#!/usr/bin/env python import re import sys def smart_input(prompt, history=None, suggestions=[], info=None): from collections import deque def ensure_file(f): import os if os.path.exists(f): return f if not os.path.exists(os.path.dirname(f)): os.makedirs(os.pat...
Python
#!/usr/bin/env python import os import re import glob import textwrap from collections import defaultdict # regex to remove the non-setname part of name cutoff = re.compile('-.*') fnparse = re.compile(""" (?P<name>[rcRC]{1,2}[12](?:\d{2}|[\d_]{4})) -(?P<pk>[\d.]+)-(?P<pdist>[\d.]+) -(?P<k>\d+)-(?P<dist>[\d.]+)-""",...
Python
#!/usr/bin/env python import sys import glob from itertools import repeat import matplotlib matplotlib.use('Qt4Agg') import pylab from matplotlib.backends.backend_qt4agg import FigureCanvasQTAgg as FigureCanvas, NavigationToolbar2QTAgg as NavigationToolbar from matplotlib.figure import Figure from PyQt4 import Qt...
Python
#!/usr/bin/env python homberger_urls = [ 'http://www.sintef.no/Projectweb/TOP/Problems/VRPTW/Homberger-benchmark/%d00-customers/' % n for n in xrange(2,11,2) ] solomon_urls = [ 'http://web.cba.neu.edu/~msolomon/c1c2solu.htm', 'http://web.cba.neu.edu/~msolomon/r1r2solu.htm', 'http://web.cba.neu.edu/~msolomon/r...
Python
from vrptw.consts import * from itertools import count def pairs(iterable): """A generator for adjacent elements of an iterable.""" it = iter(iterable) prev = it.next() for next_ in it: yield (prev, next_) prev = next_ def test_pairs(): """Unit test for pairs() generator.""" fo...
Python
# undo handlers def undo_ins(list_, idx): list_.pop(idx) def undo_pop(list_, idx, val): list_.insert(idx, val) def undo_set(list_, idx, val): list_[idx] = val def undo_atr(obj, atr, val): setattr(obj, atr, val) def undo_add(list_, idx, val): list_[idx] -= val def undo_ada(obj, atr, val): s...
Python
# Copyright 2011 The Go Authors. All rights reserved. # Use of this source code is governed by a BSD-style # license that can be found in the LICENSE file. mail_from = "Go Dashboard <builder@golang.org>" mail_submit_to = "adg@golang.org" mail_submit_subject = "New Project Submitted"
Python
# Copyright 2010 The Go Authors. All rights reserved. # Use of this source code is governed by a BSD-style # license that can be found in the LICENSE file. # This is a Django custom template filter to work around the # fact that GAE's urlencode filter doesn't handle unicode strings. from google.appengine.ext import w...
Python
# Copyright 2010 The Go Authors. All rights reserved. # Use of this source code is governed by a BSD-style # license that can be found in the LICENSE file. from google.appengine.api import mail from google.appengine.api import memcache from google.appengine.api import users from google.appengine.ext import db from goo...
Python
# Copyright 2010 The Go Authors. All rights reserved. # Use of this source code is governed by a BSD-style # license that can be found in the LICENSE file. """GDB Pretty printers and convenience functions for Go's runtime structures. This script is loaded by GDB when it finds a .debug_gdb_scripts section in the compi...
Python
# Copyright 2010 The Go Authors. All rights reserved. # Use of this source code is governed by a BSD-style # license that can be found in the LICENSE file. # This code is used to parse the debug log from gnutls-cli and generate a # script of the handshake. This script is included in handshake_server_test.go. # See the...
Python
# coding=utf-8 # (The line above is necessary so that I can use 世界 in the # *comment* below without Python getting all bent out of shape.) # Copyright 2007-2009 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 o...
Python
########################################################################### # Copyright 2010 Jim Pulokas # # This file is part of focusfun. # # focusfun is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, ...
Python
########################################################################### # Copyright 2010 Jim Pulokas # # This file is part of focusfun. # # focusfun is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, ...
Python
#!/usr/bin/env python ########################################################################### # Copyright 2010 Jim Pulokas # # This file is part of focusfun. # # focusfun is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free...
Python
#!/usr/bin/env python ########################################################################### # Copyright 2010 Jim Pulokas # # This file is part of focusfun. # # focusfun is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free...
Python
#!/usr/bin/env python ########################################################################### # Copyright 2010 Jim Pulokas # # This file is part of focusfun. # # focusfun is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free ...
Python
#!/usr/bin/env python ########################################################################### # Copyright 2010 Jim Pulokas # # This file is part of focusfun. # # focusfun is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free...
Python
#!/usr/bin/env python ########################################################################### # Copyright 2010 Jim Pulokas # # This file is part of focusfun. # # focusfun is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free ...
Python
#!/usr/bin/env python ########################################################################### # Copyright 2010 Jim Pulokas # # This file is part of focusfun. # # focusfun is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free...
Python
#!/usr/bin/env python ########################################################################### # Copyright 2010 Jim Pulokas # # This file is part of focusfun. # # focusfun is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free...
Python
#!/usr/bin/env python ########################################################################### # Copyright 2010 Jim Pulokas # # This file is part of focusfun. # # focusfun is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free...
Python
########################################################################### # Copyright 2010 Jim Pulokas # # This file is part of focusfun. # # focusfun is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, e...
Python
#!/usr/bin/env python # # Copyright 2006, 2007 Google Inc. All Rights Reserved. # Author: danderson@google.com (David Anderson) # # Script for uploading files to a Google Code project. # # This is intended to be both a useful script for people who want to # streamline project uploads and a reference implementation for ...
Python
#!/usr/bin/env python # coding: utf-8 from util import db,isint,isbigint,isvarchar,isdate,istext,issmallint from datetime import datetime is_debug=False ####### users ###### def register(i): isvarchar(i.email,1,50) isvarchar(i.password,1,100) return db.insert('users', id=i.id,email=i.ema...
Python
#!/usr/bin/env python # coding: utf-8 from util import db,isint,isbigint,isvarchar,isdate,istext,issmallint from datetime import datetime is_debug=False ####### notes ###### def create(uid,gid,content): isbigint(uid) isbigint(gid) istext(gid) summary = content[:150] return db.insert('notes', ...
Python
#!/usr/bin/env python # coding: utf-8 from util import db,isint,isbigint,isvarchar,isdate,istext,issmallint from datetime import datetime is_debug=False ####### groups ###### def create(i): isint(i.userid) isvarchar(i.name,1,50) return db.insert('groups', userid=i.userid,name=i.name,crea...
Python
#!/usr/bin/env python # coding: utf-8 import web db = web.database(dbn='mysql', db='fnotes', user='root', pw='sa') def isint(i): pass def isbigint(i): pass def isvarchar(i,min,max): pass def isdate(i): pass def istext(i): pass def issmallint(i): pass
Python
#!/usr/bin/env python # coding: utf-8 import util import groups import notes import user
Python
#!/usr/bin/env python # coding: utf-8 import web import api pre='controls.' urls=( "/api", api.app_api, '/',pre+'Index', '/ipad',pre +'iPad', '/login',pre+'Login', '/logout',pre +'Logout' ) app = web.application(urls,globals()) if web.config.get('_session') is None: session = web.session.Session(app, web.sess...
Python
#!/usr/bin/env python # coding: utf-8 import web import da render = web.template.render('templates') def getuserid(): if web.config._session.get('usr') is None: return False return web.config._session.usr.id class Index: def GET(self): uid = getuserid() if not uid: ret...
Python
#!/usr/bin/env python # coding: utf-8 import web import datetime,json,re,base64,string import da urls = ( '/groups', 'Groups', '/group/(\d+)', 'Group', '/notes/opened', 'OpenedNotes', '/notes/deleted', 'DeletedNotes', '/notes/(\d+)', 'Notes', '/note/(\d+)', 'Note', ) app_api = web.applicati...
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
# Django settings for YourSchool project. import os import ldap from django_auth_ldap.config import LDAPSearch, GroupOfNamesType #our project root folder PROJECT_PATH = os.path.abspath(os.path.dirname(__file__)) AUTHENTICATION_BACKENDS = ( 'django_auth_ldap.backend.LDAPBackend', 'django.contrib.auth.backends....
Python
from django.db import models class ExamUser(models.Model): user_name = models.CharField(max_length=64,null=False,unique=True) full_name = models.CharField(max_length=64,null=True) is_teacher=models.BooleanField(default=False) def __unicode__(self): return self.user_name class Exam(models.Model...
Python
from django.http import Http404 __author__ = 'magnusg08' from Exams.models import ExamUser,ExamQuestion,Exam,ExamOption,StudentAnswer,StudentExam #adding to ExamUsers logged in users, used in views.py index function def check_loginuser(loguser): try: obj = ExamUser.objects.get(user_name=loguser) ex...
Python
from django.db import models from django.forms.models import ModelForm from Exams.customfunctions import calculate_grade from Exams.models import Exam, ExamOption, ExamQuestion, ExamUser, StudentExam, StudentAnswer from pprint import pprint class OptionsForm(ModelForm): option = models.CharField() class QuestionF...
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.conf.urls.defaults import patterns, url urlpatterns = patterns('', (r'^index', 'YourSchool.Exams.views.index'), (r'^statistics/(?P<param_exam_id>\d+)/$', 'YourSchool.Exams.views.statistics'), (r'^create', 'YourSchool.Exams.views.create'), (r'^show/(?P<param_exam_id>\d+)/$', 'YourSchool.Exam...
Python
# Create your views here. from datetime import datetime from django.http import HttpResponseServerError from Exams.forms import ExamForm, SaveExamDataToDb, saveStudentAnswers from Exams.models import Exam, ExamUser, ExamQuestion, ExamOption, StudentExam from Exams.models import ExamUser from Exams.customfunctions impor...
Python
#!/usr/bin/env python from django.core.management import execute_manager import imp try: imp.find_module('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 t...
Python
from django.conf.urls.defaults import patterns, include, url import settings urlpatterns = patterns('', url(r'^exam/',include('Exams.urls')), (r'^exam', 'YourSchool.Exams.views.index'), (r'^$','YourSchool.Exams.views.index'), (r'^accounts/login','django.contrib.auth.views.login'), (r'^accounts/log...
Python
#!/usr/bin/env python from django.core.management import execute_manager import imp try: imp.find_module('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 t...
Python
# Django settings for YourSchool project. #import ldap #from django_auth_ldap.config import LDAPSearch, GroupOfNamesType import os DEBUG = True TEMPLATE_DEBUG = DEBUG ADMINS = ( # ('Your Name', 'your_email@example.com'), ) MANAGERS = ADMINS DATABASES = { 'default': { 'ENGINE': 'django.db...
Python
from datetime import datetime from django.db import models class Exam(models.Model): name = models.CharField(max_length=200) owner = models.CharField(max_length=200) created = models.DateTimeField(default=datetime.now()) examStartDay = models.DateField() examEndDay = models.DateField() ...
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...
Python
from datetime import date, time, timedelta from pprint import pprint from django.http import HttpResponseRedirect from exams.models import * from django.shortcuts import render_to_response, redirect, HttpResponse, RequestContext, get_object_or_404 from django.contrib.auth import logout from django.contrib.auth.de...
Python
#!/usr/bin/env python from django.core.management import execute_manager import imp try: imp.find_module('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 custo...
Python
from django.conf.urls.defaults import patterns, include, url # Uncomment the next two lines to enable the admin: from django.contrib import admin from exams import views from exams.views import * import settings admin.autodiscover() urlpatterns = patterns('', # Examples: # url(r'^$', 'YourSchool.vi...
Python
#!/usr/bin/env python from django.core.management import execute_manager import imp try: imp.find_module('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 custo...
Python
# * # * Copyright (C) 2012-2013 Garrett Brown # * Copyright (C) 2010 j48antialias # * # * This Program is free software; you can redistribute it and/or modify # * it under the terms of the GNU General Public License as published by # * the Free Software Foundation; either version 2, or (at your option) # * a...
Python
# h1. fnfal # Functional Fixed Arity Language # josh 2011-09-19 # Many times I have needed to provide some small amount of # scriptability for my programs to users reasonable well versed in # command line usage, but ignorant of the intricacies of Python # programming. This little library is a first stab at simp...
Python
#!/usr/bin/env python import time class StopWatch(object): """A small object to simulate a typical stopwatch.""" def __init__(self): self.restart() def __str__(self): return str(time.time()-self.start) def restart(self): self.start = time.time()
Python
#!/usr/bin/env python try: import argparse except ImportError: import zipfile import urllib2 import os # A non-seekable stream doesn't suffice, downloading open('argparse.zip', 'wb').write(urllib2.urlopen( 'http://argparse.googlecode.com/files/argparse-1.1.zip' ).read()) # Ext...
Python
#!/usr/bin/env python from itertools import count, izip, dropwhile from collections import deque from operator import itemgetter from bisect import bisect_left import sys import os import time import cPickle import numpy as np # additional modules from vrptw import * from vrptw.consts import * from compat import * ...
Python
#!/usr/bin/env python # may perhaps even work on systems without numpy try: import numpy except: numpy = type('dummy', (object,), dict(float64=float))() from vrptw import VrptwTask class DummyTask(VrptwTask): def __init__(self, cust = [ [0, 0, 0, 0, 0, 20, 0], [1, 1, 1, 20, 1, 5, ...
Python
from distutils.core import setup from glob import glob setup(name='Pygrout', version='0.1', description='VRPTW solving utility', author='Tomasz Gandor', url='http://code.google.com/p/pygrout/', packages=['vrptw', 'solomons', 'hombergers'], package_data = { 'vrptw': ['bestknown/*.txt...
Python
from random import Random from operator import itemgetter import time import cPickle import os import sys import numpy as np from undo import UndoStack from consts import * u = UndoStack() """Global undo - may be later made possible to override.""" r = Random() """The random number generator for the optimization."...
Python
# tuple indices in customer tuple: # number, coordinates(X,Y), demand, ready(A), due(B), service time ID, X, Y, DEM, A, B, SRV = range(7) # list indices in route list structure: # route len (num edges), capacity, total distance, edge list R_LEN, R_CAP, R_DIS, R_EDG = range(4) # list indices in edge list structure (in...
Python
#!/usr/bin/env python import sys import pstats import os def main(): if len(sys.argv) == 1: print "\nUsage: %s profile_output [sort_order] [profile_output...]" % sys.argv[0] print """ Where sort order may be: time (default), cumulative, ... (taken from documentation:) Vali...
Python
# -*- coding: utf-8 -*- # Form implementation generated from reading ui file 'helper.ui' # # Created: Mon Aug 29 16:54:25 2011 # by: PyQt4 UI code generator 4.8.3 # # WARNING! All changes made in this file will be lost! from PyQt4 import QtCore, QtGui try: _fromUtf8 = QtCore.QString.fromUtf8 except Attribut...
Python
#!/usr/bin/env python import re import sys def smart_input(prompt, history=None, suggestions=[], info=None): from collections import deque def ensure_file(f): import os if os.path.exists(f): return f if not os.path.exists(os.path.dirname(f)): os.makedirs(os.pat...
Python
#!/usr/bin/env python import os import re import glob import textwrap from collections import defaultdict # regex to remove the non-setname part of name cutoff = re.compile('-.*') fnparse = re.compile(""" (?P<name>[rcRC]{1,2}[12](?:\d{2}|[\d_]{4})) -(?P<pk>[\d.]+)-(?P<pdist>[\d.]+) -(?P<k>\d+)-(?P<dist>[\d.]+)-""",...
Python
#!/usr/bin/env python import sys import glob from itertools import repeat import matplotlib matplotlib.use('Qt4Agg') import pylab from matplotlib.backends.backend_qt4agg import FigureCanvasQTAgg as FigureCanvas, NavigationToolbar2QTAgg as NavigationToolbar from matplotlib.figure import Figure from PyQt4 import Qt...
Python
#!/usr/bin/env python homberger_urls = [ 'http://www.sintef.no/Projectweb/TOP/Problems/VRPTW/Homberger-benchmark/%d00-customers/' % n for n in xrange(2,11,2) ] solomon_urls = [ 'http://web.cba.neu.edu/~msolomon/c1c2solu.htm', 'http://web.cba.neu.edu/~msolomon/r1r2solu.htm', 'http://web.cba.neu.edu/~msolomon/r...
Python
from vrptw.consts import * from itertools import count def pairs(iterable): """A generator for adjacent elements of an iterable.""" it = iter(iterable) prev = it.next() for next_ in it: yield (prev, next_) prev = next_ def test_pairs(): """Unit test for pairs() generator.""" fo...
Python
# undo handlers def undo_ins(list_, idx): list_.pop(idx) def undo_pop(list_, idx, val): list_.insert(idx, val) def undo_set(list_, idx, val): list_[idx] = val def undo_atr(obj, atr, val): setattr(obj, atr, val) def undo_add(list_, idx, val): list_[idx] -= val def undo_ada(obj, atr, val): s...
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
import os, time class MyException(Exception): pass def passing(*args): pass def sleeping(s): seconds = s while seconds > 0: time.sleep(min(seconds, 0.1)) seconds -= 0.1 os.environ['ROBOT_THREAD_TESTING'] = str(s) return s def returning(arg): return arg def failing(msg='...
Python
#!/usr/bin/env python """Helper script to run all Robot Framework's unit tests. usage: run_utest.py [options] options: -q, --quiet Minimal output -v, --verbose Verbose output -d, --doc Show test's doc string instead of name and class (implies verbosity) -h, --help ...
Python
#!/usr/bin/env python import urllib2 import shutil import os from os.path import join, exists, dirname, abspath from glob import glob from subprocess import call from zipfile import ZipFile JASMINE_REPORTER_URL='https://github.com/larrymyers/jasmine-reporters/zipball/0.2.1' BASE = abspath(dirname(__file__)) REPORT_DI...
Python
MY_VARIABLE = "An example string"
Python
import sys from os import remove from os.path import exists import unittest from StringIO import StringIO class RunningTestCase(unittest.TestCase): remove_files = [] def setUp(self): self.orig__stdout__ = sys.__stdout__ self.orig__stderr__ = sys.__stderr__ self.orig_stdout = sys.stdo...
Python
import os THIS_PATH = os.path.dirname(__file__) GOLDEN_OUTPUT = os.path.join(THIS_PATH, 'golden_suite', 'output.xml') GOLDEN_OUTPUT2 = os.path.join(THIS_PATH, 'golden_suite', 'output2.xml') GOLDEN_JS = os.path.join(THIS_PATH, 'golden_suite', 'expected.js')
Python
__author__ = 'janne'
Python
#!/usr/bin/env python import fileinput from os.path import join, dirname, abspath import sys import os BASEDIR = dirname(abspath(__file__)) OUTPUT = join(BASEDIR, 'output.xml') sys.path.insert(0, join(BASEDIR, '..', '..', '..', '..', 'src')) import robot from robot.conf.settings import RebotSettings from robot.repo...
Python