code
stringlengths
1
1.72M
language
stringclasses
1 value
# Written by Bram Cohen # see LICENSE.txt for license information from zurllib import urlopen from urlparse import urljoin from btformats import check_message from Choker import Choker from Storage import Storage from StorageWrapper import StorageWrapper from Uploader import Upload from Downloader import Downloader fr...
Python
# Written by Bram Cohen # see LICENSE.txt for license information from types import StringType, LongType, IntType, ListType, DictType from re import compile reg = compile(r'^[^/\\.~][^/\\]*$') ints = (LongType, IntType) def check_info(info): if type(info) != DictType: raise ValueError, 'bad metainfo - n...
Python
version = '3.4.2'
Python
# Written by Bram Cohen # see LICENSE.txt for license information from zurllib import urlopen, quote from btformats import check_peers from bencode import bdecode from threading import Thread, Lock from socket import error from time import time from random import randrange from binascii import b2a_hex class Rerequest...
Python
# Written by Bram Cohen # see LICENSE.txt for license information from time import time class RateMeasure: def __init__(self, left): self.start = None self.last = None self.rate = 0 self.remaining = None self.left = left self.broke = False self.got_anything ...
Python
# Written by Bram Cohen # see LICENSE.txt for license information from sha import sha from threading import Event from bitfield import Bitfield def dummy_status(fractionDone = None, activity = None): pass def dummy_data_flunked(size): pass class StorageWrapper: def __init__(self, storage, request_size, ...
Python
# Written by Bram Cohen # see LICENSE.txt for license information from parseargs import parseargs, formatDefinitions from RawServer import RawServer from HTTPHandler import HTTPHandler from NatCheck import NatCheck from threading import Event from bencode import bencode, bdecode, Bencached from zurllib import urlopen,...
Python
# Written by Michael Janssen # See LICENSE.txt for license information def fmttime(n, compact = 0): if n == -1: if compact: return '(no seeds?)' else: return 'download not progressing (no seeds?)' if n == 0: if compact: return "complete" el...
Python
# Written by Bram Cohen # see LICENSE.txt for license information from cStringIO import StringIO from socket import error as socketerror protocol_name = 'BitTorrent protocol' # header, reserved, download id, my id, [length, message] class NatCheck: def __init__(self, resultfunc, downloadid, peerid, ip, port, ra...
Python
# Written by Bram Cohen # see LICENSE.txt for license information from CurrentRateMeasure import Measure class Upload: def __init__(self, connection, choker, storage, max_slice_length, max_rate_period, fudge): self.connection = connection self.choker = choker self.storage = st...
Python
""" xbee.py By Paul Malmsten, 2010 Inspired by code written by Amit Synderman and Marco Sangalli pmalmsten@gmail.com XBee superclass module This class defines data and methods common to all XBee modules. This class should be subclassed in order to provide series-specific functionality. """ import struct, threading,...
Python
""" zigbee.py By Greg Rapp, 2010 Inspired by code written by Paul Malmsten, 2010 Inspired by code written by Amit Synderman and Marco Sangalli gdrapp@gmail.com This module implements an XBee ZB (ZigBee) API library. """ import struct from xbee.base import XBeeBase from xbee.python2to3 import byteToInt, intToByte cla...
Python
""" dispatch.py By Paul Malmsten, 2010 pmalmsten@gmail.com Provides the Dispatch class, which allows one to filter incoming data packets from an XBee device and call an appropriate method when one arrives. """ from xbee import XBee class Dispatch(object): def __init__(self, ser=None, xbee=None): self.xb...
Python
""" fake.py By Paul Malmsten, 2010 pmalmsten@gmail.com Provides fake objects for testing the dispatch package. """ class FakeXBee(object): """ Represents an XBee device from which data can be read. """ def __init__(self, data): self.data = data def wait_read_frame(self): ...
Python
from xbee.helpers.dispatch.dispatch import Dispatch
Python
""" python2to3.py By Paul Malmsten, 2011 Helper functions for handling Python 2 and Python 3 datatype shenanigans. """ def byteToInt(byte): """ byte -> int Determines whether to use ord() or not to get a byte's value. """ if hasattr(byte, 'bit_length'): # This is already an int return byte return ord(byt...
Python
""" frame.py By Paul Malmsten, 2010 pmalmsten@gmail.com Represents an API frame for communicating with an XBee """ import struct from xbee.python2to3 import byteToInt, intToByte class APIFrame: """ Represents a frame of data to be sent to or which was received from an XBee device """ START_...
Python
#! /usr/bin/python """ Fake.py By Paul Malmsten, 2010 pmalmsten@gmail.com Provides fake device objects for other unit tests. """ import sys class FakeDevice(object): """ Represents a fake serial port for testing purposes """ def __init__(self): self.data = b'' def w...
Python
""" ieee.py By Paul Malmsten, 2010 Inspired by code written by Amit Synderman and Marco Sangalli pmalmsten@gmail.com This module provides an XBee (IEEE 802.15.4) API library. """ import struct from xbee.base import XBeeBase class XBee(XBeeBase): """ Provides an implementation of the XBee API for IEEE 802.15....
Python
""" XBee package initalization file By Paul Malmsten, 2010 pmalmsten@gmail.com """ from xbee.ieee import XBee from xbee.zigbee import ZigBee
Python
#! /usr/bin/python """ receive_samples_async.py By Paul Malmsten, 2010 pmalmsten@gmail.com This example reads the serial port and asynchronously processes IO data received from a remote XBee. """ from xbee import XBee import time import serial PORT = '/dev/ttyUSB0' BAUD_RATE = 9600 # Open serial port ser = serial...
Python
#! /usr/bin/python """ dispatch_async.py By Paul Malmsten, 2010 pmalmsten@gmail.com This example continuously reads the serial port and dispatches packets which arrive to appropriate methods for processing in a separate thread. """ from xbee import XBee from xbee.helpers.dispatch import Dispatch import time import ...
Python
#! /usr/bin/python from xbee import XBee import serial """ serial_example.py By Paul Malmsten, 2010 Demonstrates reading the low-order address bits from an XBee Series 1 device over a serial port (USB) in API-mode. """ def main(): """ Sends an API AT command to read the lower-order address bits from an...
Python
#! /usr/bin/python """ receive_samples.py By Paul Malmsten, 2010 pmalmsten@gmail.com This example continuously reads the serial port and processes IO data received from a remote XBee. """ from xbee import XBee import serial PORT = '/dev/ttyUSB0' BAUD_RATE = 9600 # Open serial port ser = serial.Serial(PORT, BAUD_R...
Python
#! /usr/bin/python """ dispatch.py By Paul Malmsten, 2010 pmalmsten@gmail.com This example continuously reads the serial port and dispatches packets which arrive to appropriate methods for processing. """ from xbee.helpers.dispatch import Dispatch import serial PORT = '/dev/ttyUSB0' BAUD_RATE = 9600 # Open serial...
Python
#! /usr/bin/python """ alarm.py By Paul Malmsten, 2010 pmalmsten@gmail.com This module will communicate with a remote XBee device in order to implement a simple alarm clock with bed occupancy detection. """ import serial from xbee import XBee class DataSource(object): """ Represents a source from which ala...
Python
#! /usr/bin/python """ led_adc_example.py By Paul Malmsten, 2010 pmalmsten@gmail.com A simple example which sets up a remote device to read an analog value on ADC0 and a digital output on DIO1. It will then read voltage measurements and write an active-low result to the remote DIO1 pin. """ from xbee import XBee i...
Python
""" distutils_extensions.py By Paul Malmsten, 2010 pmalmsten@gmail.com Provides distutils extension code for running tests """ from distutils.core import Command from distutils.command.build_py import build_py as _build_py import sys class TestCommand(Command): description = "Runs automated tests" user_optio...
Python
#!/usr/bin/env python """ shell.py Amit Snyderman, 2009 <amit@amitsnyderman.com> Updated by Paul Malmsten, 2010 pmalmsten@gmail.com Provides a simple shell for testing XBee devices. Currently, the shell only allows one to parse and print received data; sending is not supported. """ # $Id: xbee-serial-terminal.py 7 2...
Python
from distutils.core import setup packages=[ 'xbee', 'xbee.tests', 'xbee.helpers', 'xbee.helpers.dispatch', 'xbee.helpers.dispatch.tests', ] setup( name='XBee', version='2.0.0', author='Paul Malmsten', author_email='pmalmsten@gmail.com', packages=packages, scripts=[], ...
Python
from naoqi import * import time class RecordWavModule(ALModule): def __init__( self, strName, IP, frequency, activeChannels, pathToNao): ALModule.__init__(self, strName); self.Ip = IP self.ALAudioRecProxy = ALProxy("ALAudioRecorder", IP, 9559) self.channels = activeChannels ...
Python
import sys from naoqi import ALBroker from commandLineHandler import CommandLineHandler from recordWav import RecordWavModule from audioSoundProcessing import SoundProcessingModule from controlNao import ControlNaoModule from commandParser import CommandParser from aaltoASRInterface import AaltoASRInterface import...
Python
import subprocess class CommandLineHandler(object): def __init__(self, IP, password): self.IP = IP self.password = password def transfer_file(self, original_filepath, new_filepath): try: subprocess.check_call(["sshpass", "-p", self.passw...
Python
import sys import ConfigParser class CommParser(ConfigParser.ConfigParser): def as_dict(self): d = dict(self._sections) for key in d: d[key] = dict(self._defaults, **d[key]) d[key].pop('__name__', None) for key in d["COMMANDS"]: val_list = d["...
Python
# -*- encoding: UTF-8 -*- """ This script gets the signal from the front microphone of Nao and calculates the rms power on it It requires numpy """ from naoqi import * import time import numpy as np class SoundProcessingModule(ALModule): def __init__( self, strName, robotIP,threshold): ...
Python
import sys import time from naoqi import ALProxy from naoqi import ALModule from naoqi import ALBroker import motion class ControlNaoModule(ALModule): ''' Class for sending control commands to NAO ''' def __init__( self,moduleName ,robotIP): ALModule.__init__(self,moduleName) #Ini...
Python
import subprocess import time class AaltoASRInterface(object): """ This module is used to interface with the AaltoASR recognition library through terminal commands. """ def __init__(self, exe_path="./decode-stream-wav"): """ This is given a path to the location of the C++ executab...
Python
# -*- encoding: UTF-8 -*- """ This script gets the signal from the front microphone of Nao and calculates the rms power on it It requires numpy """ from naoqi import * import time import numpy as np class SoundProcessingModule(ALModule): def __init__( self, strName): ALModule.__init__( self, strName ...
Python
# -*- encoding: UTF-8 -*- """ Say 'hello, you' each time a human face is detected """ import sys import time from naoqi import ALProxy from naoqi import ALBroker from naoqi import ALModule from optparse import OptionParser NAO_IP = "nao.local" # Global variable to store the HumanGreeter module instance HumanGree...
Python
from naoqi import * import time class RecordWavModule(ALModule): def __init__( self, strName, IP): ALModule.__init__(self, strName); self.Ip = IP self.ALAudioRecProxy = ALProxy("ALAudioRecorder", IP, 9559) self.channels =[] self.initChannels() ...
Python
# PYTHON KOODI JOKA TEKEE ITSE TUNNISTUKSEN toolbox.set_generate_word_graph(0) toolbox.set_keep_state_segmentation(0); toolbox.lna_open(lna_path, 1024) toolbox.reset(0) toolbox.set_end(-1) while toolbox.run(): pass # We have to open with only "w" first, and then later with "r" # for reading, or the file will not ...
Python
#!/usr/bin/python import time import string import sys import os import re # Set your decoder swig path in here! sys.path.append("/home/jerry/AaltoASR/build/decoder/src/swig"); import Decoder def runto(frame): while (frame <= 0 or t.frame() < frame): if (not t.run()): break def rec(start, e...
Python
#!/usr/bin/python import time import string import sys import os import re # Set your decoder swig path in here! sys.path.append("/home/jerry/AaltoASR/build/decoder/src/swig"); import Decoder def runto(frame): while (frame <= 0 or t.frame() < frame): if (not t.run()): break def rec(start, e...
Python
# -*- coding: UTF-8 -*- import random rand = random.Random() rand.seed() def intRandom(a): return rand.randint(0,a) def Clamp(x, minval = None, maxval = None): if minval != None: x = max(minval, x) if maxval != None: x = min(maxval, x) return x
Python
# -*- coding: UTF-8 -*- class Movable(object): def __init__(self, pos = (0, 0), direction = (0,0), delta_dx = 0): self.x,self.y = pos self.direction = direction self.delta_dx = delta_dx def move(self, time_passed = 0): dx, dy = self.direction self.x += dx * time_passed ...
Python
#!/usr/bin/python # -*- coding: UTF-8 -*- import pygame from tile import * from pygame.locals import * from camera import Camera from guy import Guy from background import * CLOCK_TICK = 25 SECOND_TICK = 26 Game = None class FireGame: size = None def __init__(self): # Initialize PyGame pyga...
Python
import pygame class Background(pygame.Surface): def __init__(self, name, size): self.image = pygame.image.load(name) self.image = pygame.transform.scale(self.image, (size[0], size[1])).convert() x,y = self.image.get_size() self.image = pygame.transform.scale(self.image, (x*...
Python
from utils import * class Camera(object): def __init__(self, game): self.x, self.y = (0,0) self.screen = game.screen self.size = game.screen_size def set_limits(self, minx, maxx, miny, maxy): self.minx = minx self.maxx = maxx self.miny = miny self.ma...
Python
# -*- coding: UTF-8 -*- import pygame from utils import * from movable import Movable global Game class BurningTile(pygame.sprite.Sprite, Movable): size = 20 energyColor = {} def __init__(self, pos, *args, **kwargs): pygame.sprite.Sprite.__init__(self) self.image = pygame.Surface([self.si...
Python
#!/usr/bin/python # -*- coding: UTF-8 -*- import pygame from tile import * from pygame.locals import * from camera import Camera from guy import Guy from background import * CLOCK_TICK = 25 SECOND_TICK = 26 Game = None class FireGame: size = None def __init__(self): # Initialize PyGame pyga...
Python
# -*- coding: UTF-8 -*- from pygame.locals import * from utils import * from tile import BurningTile from movable import Movable import pygame class Guy(pygame.sprite.Sprite, Movable): events = [K_UP, K_DOWN, K_LEFT, K_RIGHT, K_SPACE] game = None def __init__(self, pos, game): pygame.sprite.S...
Python
#!/usr/bin/env python """Universal feed parser Handles RSS 0.9x, RSS 1.0, RSS 2.0, CDF, Atom 0.3, and Atom 1.0 feeds Visit http://feedparser.org/ for the latest version Visit http://feedparser.org/docs/ for the latest documentation Required: Python 2.4 or later Recommended: CJKCodecs and iconv_codec <http://cjkpytho...
Python
import unittest import mox import clients import client_model from datetime import datetime from google.appengine.ext import db from google.appengine.api import channel # Import the 'testbed' module. from google.appengine.ext import testbed class ClientsUnitTest(unittest.TestCase): def setUp(self): self.mox =...
Python
"""A parser for SGML, using the derived class as a static DTD.""" # XXX This only supports those SGML features used by HTML. # XXX There should be a way to distinguish between PCDATA (parsed # character data -- the normal case), RCDATA (replaceable character # data -- only char and entity references and end tags are ...
Python
#!/usr/bin/python import optparse import sys # Note that you have to install the unittest2 package, first. import unittest2 USAGE = """%prog SDK_PATH TEST_PATH Run unit tests for App Engine apps. SDK_PATH Path to the SDK installation TEST_PATH Path to package containing test modules""" def main(sdk_path, test_...
Python
#!/usr/bin/env python """Universal feed parser Handles RSS 0.9x, RSS 1.0, RSS 2.0, CDF, Atom 0.3, and Atom 1.0 feeds Visit http://feedparser.org/ for the latest version Visit http://feedparser.org/docs/ for the latest documentation Required: Python 2.4 or later Recommended: CJKCodecs and iconv_codec <http://cjkpytho...
Python
import clients import pshb_client import feedparser import logging import urllib import os import zlib from datetime import datetime from datetime import timedelta from django.utils import simplejson from google.appengine.api import app_identity from google.appengine.api import channel from google.appengine.ext impor...
Python
#!/usr/bin/python import optparse import sys # Note that you have to install the unittest2 package, first. import unittest2 USAGE = """%prog SDK_PATH TEST_PATH Run unit tests for App Engine apps. SDK_PATH Path to the SDK installation TEST_PATH Path to package containing test modules""" def main(sdk_path, test_...
Python
import client_model import feedparser import logging from datetime import datetime from datetime import timedelta from django.utils import simplejson from google.appengine.api import channel from google.appengine.ext import db from google.appengine.api import memcache # Channel API tokens expire after two hours. TOKE...
Python
import feedparser import logging import urllib import zlib from django.utils import simplejson from google.appengine.api import app_identity from google.appengine.api import memcache from google.appengine.api import taskqueue from google.appengine.api import urlfetch from google.appengine.ext import webapp class SubC...
Python
from google.appengine.ext import db class Client(db.Model): """A record of a client connection. The string representation of the 'created' field is the clientid used by the Channel API """ created = db.DateTimeProperty(required=True, auto_now_add=True) feeds = db.StringListProperty(required=True) connected...
Python
from setuptools import setup, find_packages setup( name='firepy', version='0.1.5', description='FirePHP for Python', long_description=('This is a python server library for FirePHP ' 'supporting python built-in logging facility ' 'and D...
Python
# The MIT License # # Copyright (c) 2009 Sung-jin Hong <serialx@serialx.net> # Many code here derived from: # http://code.cmlenz.net/diva/browser/trunk/diva/ext/firephp.py # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Softw...
Python
# The MIT License # # Copyright (c) 2009 Sung-jin Hong <serialx@serialx.net> # Many code here derived from: # http://code.cmlenz.net/diva/browser/trunk/diva/ext/firephp.py # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Softw...
Python
# The MIT License # # Copyright (c) 2009 Sung-jin Hong <serialx@serialx.net> # Many code here derived from: # http://code.cmlenz.net/diva/browser/trunk/diva/ext/firephp.py # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Softw...
Python
# The MIT License # # Copyright (c) 2009 Sung-jin Hong <serialx@serialx.net> # Many code here derived from: # http://code.cmlenz.net/diva/browser/trunk/diva/ext/firephp.py # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Softw...
Python
#!/usr/bin/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 run ...
Python
import sys def func(): frame = sys._getframe() tb = frame.f_back f_code = tb.f_code print f_code.co_filename, ':', f_code.co_name , tb.f_lineno print dir(frame) print dir(tb) print dir(f_code) def func2(): func() func2()
Python
#!/usr/bin/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 run ...
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('', # Example: # (r'^fire/', include('firephp.fire.urls')), (r'^fire/', 'firephp.fire.views.fire'), # Uncomment the admin/doc li...
Python
# Django settings for firephp project. DEBUG = True TEMPLATE_DEBUG = DEBUG ADMINS = ( # ('Your Name', 'your_email@domain.com'), ) MANAGERS = ADMINS DATABASE_ENGINE = 'sqlite3' # 'postgresql_psycopg2', 'postgresql', 'mysql', 'sqlite3' or 'oracle'. DATABASE_NAME = 'test.db' # Or path to data...
Python
from django.db import models # Create your models here.
Python
# The MIT License # # Copyright (c) 2009 Sung-jin Hong <serialx@serialx.net> # # 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 #...
Python
from __future__ import division import pylab as pl import numpy as np import pandas as pd class tctGibbs: #initialization # inputs: def __init__(self,cro=76,cbu=20,cwo=4,talup=120,tallow=90, tdisup=80,tdislow=40,tturup=100,tturlow=60,tarrup=420, tarrlow=300,tsup...
Python
from __future__ import division import matplotlib matplotlib.use('Agg') import numpy as np from pylab import * import pandas as pd # Optimization class for finding tct class tctOptim: # Initialization # Inputs: total number of fires, true number of fires in each bin (list) def __init__(self,total_fires,tru...
Python
import psycopg2 import random class DISTImport(object): """Contains the import methods for the DIST model. The DistImport class contains the import methods for the DIST model. Additionally, it stores the relevant input parameters used by other aspects of the model in attributes. Attribu...
Python
import numpy as np import DIST_import import DIST_calculations import DIST_output floor_extent=False #import all the values Dimport = DIST_import.DISTImport() #Dimport.pgdb_import('nfirs2','postgres','localhost','password','table(or_view?)ofstructurefires') Dimport.set_firespread_count([93,190,39,64,9]) Di...
Python
from __future__ import division import numpy as np import copy import matplotlib.pyplot as plt class DISTOutput(object): """Contains the output methods for the DIST model. The DistOutput class contains the output methods for the DIST model. Note that this class does not contain the raw output v...
Python
from __future__ import division import random from math import log class DISTCalculate(object): """Contains the calculation methods for the DIST model. The DISTCalculate class contains the calculation methods for the DIST model. Additionally, it possesses attributes tracking present values of rand...
Python
from __future__ import division import pylab as pl import numpy as np import pandas as pd class tctGibbs: #initialization # inputs: def __init__(self,cro=76,cbu=20,cwo=4,talup=120,tallow=90, tdisup=80,tdislow=40,tturup=100,tturlow=60,tarrup=420, tarrlow=300,tsup...
Python
#Anderson #2-19 from __future__ import division import numpy as np import pandas as pd from pylab import * import random #import the data incidents = pd.read_csv('../Data/ArlingtonCensusFireDataYearly.csv') #aggregate the yearly number of residential structure fires that ACFD responded to yeardist = incid...
Python
#Weinschenk #12-14 from __future__ import division import numpy as np import pandas as pd from pylab import * from matplotlib import rcParams rcParams.update({'figure.autolayout': True}) import random incident = pd.read_csv('../Data/arlington_incidents.csv', header=0) total_incidents = len(incident['incident_class_co...
Python
#!/usr/bin/env python # encoding: utf-8 """ Utility script to patch a cmake project and convert a target to a browser plugin compatible bundle Original Author(s): Richard Bateman Created: 15 January 2010 License: Dual license model; choose one of two: New BSD License http://www.opensource...
Python
#!/usr/bin/env python # encoding: utf-8 """ Utility script to generate/modify Firebreath plug-in projects. Original Author(s): Ben Loveridge, Richard Bateman Created: 14 December 2009 License: Dual license model; choose one of two: New BSD License http://www.opensource.org/licenses/bsd-li...
Python
#!/usr/bin/env python # encoding: utf-8 """ Utility script to import doxygen docs into confluence Original Author(s): Richard Bateman Created: 18 October 2009 License: Dual license model; choose one of two: New BSD License http://www.opensource.org/licenses/bsd-license.php - o...
Python
# ############################################################ # Original Author: Georg Fritzsche # # Created: November 6, 2009 # License: Dual license model; choose one of two: # New BSD License # http://www.opensource.org/licenses/bsd-license.php # - or - # GNU Le...
Python
#!/usr/bin/env python import os, re, string, sys, uuid class AttrDictSimple(dict): def __getattr__(self, attr): return self[attr] def __setattr__(self, attr, value): self[attr] = value def __delattr__(self, attr): del self[attr] class Template(string.Template): delimiter = "@" def __init__(self,...
Python
#!/usr/bin/python """ Runs javac -Xlint on all files in all subdirectories. Collects results into JavaLint.txt """ import os outputfile = "JavaLint.txt" javadirs = [] for path, dirs, files in os.walk('.'): for file in files: if file.endswith(".java"): javadirs.append(path) ...
Python
"""FindBugsExcluder.py Creates a filter file from the xml and text output of FindBugs To prepare, you must run findbugs -textui . > findbugs.txt findbugs -textui -xml . > findbugs.xml Once you've run this program you can then run findbugs -textui -exclude FindBugsFilter-auto.xml . To exclude the bugs that have b...
Python
#!/usr/bin/python """ To do: 3) command-line argument (to test a single file) - What about exceptions and aborts? -If ...is embedded anywhere in a line, that portion becomes a .*? regexp --------------- Find files with /* Output: Run the programs and capture the output, compare with anticipated outpu...
Python
"""RedundantImportDetector.py Discover redundant java imports using brute force. Requires Python 2.3""" import os, sys, re from glob import glob reportFile = file("RedundantImports.txt", 'w') startDir = 'D:\\aaa-TIJ4\\code' # Regular expression to find the block of import statements: findImports = re.comp...
Python
#!/usr/bin/python """ Eclipse.py by Bruce Eckel, for Thinking in Java 4e Modify or insert package statments so that Eclipse is happy with the code tree. Run this with no arguments from the root of the code tree. The Ant build will not work once you run this program! You may also want to modify the dotproject ...
Python
#!/usr/bin/python """ DEclipse.py by Bruce Eckel, for Thinking in Java 4e Undoes the effect of Eclipse.py, so that Ant can be used again to build the code tree. You must have Python 2.3 installed to run this program. See www.python.org. """ import os for path, dirs, files in os.walk('.'): for file in...
Python
#!/usr/bin/python """ To do: 3) command-line argument (to test a single file) - What about exceptions and aborts? -If ...is embedded anywhere in a line, that portion becomes a .*? regexp --------------- Find files with /* Output: Run the programs and capture the output, compare with anticipated outpu...
Python
#!/usr/bin/python """ Eclipse.py by Bruce Eckel, for Thinking in Java 4e Modify or insert package statments so that Eclipse is happy with the code tree. Run this with no arguments from the root of the code tree. The Ant build will not work once you run this program! You may also want to modify the dotproject ...
Python
#!/usr/bin/python """ DEclipse.py by Bruce Eckel, for Thinking in Java 4e Undoes the effect of Eclipse.py, so that Ant can be used again to build the code tree. You must have Python 2.3 installed to run this program. See www.python.org. """ import os for path, dirs, files in os.walk('.'): for file in...
Python
#!/usr/bin/python """ Runs javac -Xlint on all files in all subdirectories. Collects results into JavaLint.txt """ import os outputfile = "JavaLint.txt" javadirs = [] for path, dirs, files in os.walk('.'): for file in files: if file.endswith(".java"): javadirs.append(path) ...
Python
#!/usr/bin/python """ Runs a Java program, appends output if it's not there -force as first argument when doing batch files forces overwrite """ import os, re, sys argTag = '// {Args: ' oldOutput = re.compile("/* Output:.*?\n(.*)\n\*///:~(?s)") def makeOutputIncludedFile(path, fileName, changeReport, fo...
Python
#!/usr/bin/python """ Runs a Java program, appends output if it's not there -force as first argument when doing batch files forces overwrite """ import os, re, sys argTag = '// {Args: ' oldOutput = re.compile("/* Output:.*?\n(.*)\n\*///:~(?s)") def makeOutputIncludedFile(path, fileName, changeReport, fo...
Python
''' Created on 2012-7-27 @author: root ''' import os import glob import time #更改当前的工作目录 os.chdir('/usr/eclipse/pythonjellybean/src/cn/taylor/jellybean/pythonDataType') #找出当前所有的文件,用到通配符 filelist = glob.glob('*.py') print(filelist) fullFileList = [os.path.realpath(elem) for elem in filelist] print(fullFileList) metada...
Python