rem
stringlengths
0
322k
add
stringlengths
0
2.05M
context
stringlengths
8
228k
print "warning: %s exists but isn't included in %s" % (missing_file, dat_list_file_path)
relative_path = "/".join(missing_file.split("/")[-2:]) print "warning: missing data for supported locale: %s" % relative_path
def GenResIndex(dat_list_file_path): res_index = "res_index.txt" brkitrs = set() colls = set() currs = set() langs = set() locales = set() regions = set() zones = set() for line in open(dat_list_file_path, "r"): if "root." in line or "res_index" in line or "_.res" in line: continue; if "brkitr/" in line: AddResFile(b...
def CopyAndroidCnvFiles(icu_dat_path):
def CopyAndroidCnvFiles(stubdata_dir):
def CopyAndroidCnvFiles(icu_dat_path): android_specific_cnv = ["gsm-03.38-2000.cnv", "iso-8859_16-2001.cnv", "docomo-shift_jis-2007.cnv", "kddi-jisx-208-2007.cnv", "kddi-shift_jis-2007.cnv", "softbank-jisx-208-2007.cnv", "softbank-shift_jis-2007.cnv"] for cnv_file in android_specific_cnv: source_path = os.path.join(icu...
source_path = os.path.join(icu_dat_path, "cnv", cnv_file) dest_path = os.path.join(TMP_DAT_PATH, cnv_file) shutil.copyfile(source_path, dest_path)
src_path = os.path.join(stubdata_dir, "cnv", cnv_file) dst_path = os.path.join(TMP_DAT_PATH, cnv_file) shutil.copyfile(src_path, dst_path)
def CopyAndroidCnvFiles(icu_dat_path): android_specific_cnv = ["gsm-03.38-2000.cnv", "iso-8859_16-2001.cnv", "docomo-shift_jis-2007.cnv", "kddi-jisx-208-2007.cnv", "kddi-shift_jis-2007.cnv", "softbank-jisx-208-2007.cnv", "softbank-shift_jis-2007.cnv"] for cnv_file in android_specific_cnv: source_path = os.path.join(icu...
print "copy " + source_path + " " + dest_path
print "copy " + src_path + " " + dst_path
def CopyAndroidCnvFiles(icu_dat_path): android_specific_cnv = ["gsm-03.38-2000.cnv", "iso-8859_16-2001.cnv", "docomo-shift_jis-2007.cnv", "kddi-jisx-208-2007.cnv", "kddi-shift_jis-2007.cnv", "softbank-jisx-208-2007.cnv", "softbank-shift_jis-2007.cnv"] for cnv_file in android_specific_cnv: source_path = os.path.join(icu...
global ICU4C_DIR global ICU_VERSION
global ICU4C_DIR global ICU_PREBUILT_DIR
def main(): global ANDROID_BUILD_TOP # $ANDROID_BUILD_TOP global ICU4C_DIR # $ANDROID_BUILD_TOP/external/icu4c global ICU_VERSION # ICU version number global ICUDATA # e.g. "icudt42l" global ICUDATA_DAT # e.g. "icudt42l.dat" global CLDR_VERSION # CLDR version. The value can be vary upon ICU release. glo...
global ICUDATA_DAT global CLDR_VERSION
global CLDR_VERSION
def main(): global ANDROID_BUILD_TOP # $ANDROID_BUILD_TOP global ICU4C_DIR # $ANDROID_BUILD_TOP/external/icu4c global ICU_VERSION # ICU version number global ICUDATA # e.g. "icudt42l" global ICUDATA_DAT # e.g. "icudt42l.dat" global CLDR_VERSION # CLDR version. The value can be vary upon ICU release. glo...
opts, args = getopt.getopt(sys.argv[1:], 'hv', ['help', 'verbose'])
opts, args = getopt.getopt(sys.argv[1:], "hv", ["help", "verbose"])
def main(): global ANDROID_BUILD_TOP # $ANDROID_BUILD_TOP global ICU4C_DIR # $ANDROID_BUILD_TOP/external/icu4c global ICU_VERSION # ICU version number global ICUDATA # e.g. "icudt42l" global ICUDATA_DAT # e.g. "icudt42l.dat" global CLDR_VERSION # CLDR version. The value can be vary upon ICU release. glo...
for opt, arg in opts: if opt in ('-h', '--help'):
for opt, _ in opts: if opt in ("-h", "--help"):
def main(): global ANDROID_BUILD_TOP # $ANDROID_BUILD_TOP global ICU4C_DIR # $ANDROID_BUILD_TOP/external/icu4c global ICU_VERSION # ICU version number global ICUDATA # e.g. "icudt42l" global ICUDATA_DAT # e.g. "icudt42l.dat" global CLDR_VERSION # CLDR version. The value can be vary upon ICU release. glo...
elif opt in ('-v', '--verbose'):
elif opt in ("-v", "--verbose"):
def main(): global ANDROID_BUILD_TOP # $ANDROID_BUILD_TOP global ICU4C_DIR # $ANDROID_BUILD_TOP/external/icu4c global ICU_VERSION # ICU version number global ICUDATA # e.g. "icudt42l" global ICUDATA_DAT # e.g. "icudt42l.dat" global CLDR_VERSION # CLDR version. The value can be vary upon ICU release. glo...
if len(args) < 1:
if args:
def main(): global ANDROID_BUILD_TOP # $ANDROID_BUILD_TOP global ICU4C_DIR # $ANDROID_BUILD_TOP/external/icu4c global ICU_VERSION # ICU version number global ICUDATA # e.g. "icudt42l" global ICUDATA_DAT # e.g. "icudt42l.dat" global CLDR_VERSION # CLDR version. The value can be vary upon ICU release. glo...
ICU_VERSION = args[0] if re.search(r'[0-9]+\.[0-9]+', ICU_VERSION) == None: print "'%s' is not a valid icu version number!" % (ICU_VERSION) sys.exit(1) ICUDATA = "icudt" + re.sub(r'([^0-9])', "", ICU_VERSION) + "l" CLDR_VERSION = "1.8"
def main(): global ANDROID_BUILD_TOP # $ANDROID_BUILD_TOP global ICU4C_DIR # $ANDROID_BUILD_TOP/external/icu4c global ICU_VERSION # ICU version number global ICUDATA # e.g. "icudt42l" global ICUDATA_DAT # e.g. "icudt42l.dat" global CLDR_VERSION # CLDR version. The value can be vary upon ICU release. glo...
ICUDATA_DAT = ICUDATA + ".dat"
def main(): global ANDROID_BUILD_TOP # $ANDROID_BUILD_TOP global ICU4C_DIR # $ANDROID_BUILD_TOP/external/icu4c global ICU_VERSION # ICU version number global ICUDATA # e.g. "icudt42l" global ICUDATA_DAT # e.g. "icudt42l.dat" global CLDR_VERSION # CLDR version. The value can be vary upon ICU release. glo...
datlist = ["us", "us-euro", "default", "us-japan", "zh", "medium", "large"] for dat_subtag in datlist: output_filename = os.path.join(stubdata_dir, ICUDATA + "-" + dat_subtag + ".dat") MakeDat(stubdata_dir, dat_subtag) shutil.copyfile(os.path.join(TMP_DAT_PATH, ICUDATA_DAT), output_filename) print "Generated ICU data:...
for input_file in sorted(input_files): output_file = input_file[:-3] + "dat" MakeDat(input_file, stubdata_dir) shutil.copyfile(os.path.join(TMP_DAT_PATH, ICUDATA + ".dat"), output_file) print "Generated ICU data: %s" % output_file
def main(): global ANDROID_BUILD_TOP # $ANDROID_BUILD_TOP global ICU4C_DIR # $ANDROID_BUILD_TOP/external/icu4c global ICU_VERSION # ICU version number global ICUDATA # e.g. "icudt42l" global ICUDATA_DAT # e.g. "icudt42l.dat" global CLDR_VERSION # CLDR version. The value can be vary upon ICU release. glo...
os.remove(os.path.join(stubdata_dir, ICUDATA_DAT))
os.remove(os.path.join(stubdata_dir, ICUDATA + ".dat"))
def main(): global ANDROID_BUILD_TOP # $ANDROID_BUILD_TOP global ICU4C_DIR # $ANDROID_BUILD_TOP/external/icu4c global ICU_VERSION # ICU version number global ICUDATA # e.g. "icudt42l" global ICUDATA_DAT # e.g. "icudt42l.dat" global CLDR_VERSION # CLDR version. The value can be vary upon ICU release. glo...
print "icu_dat_generator.py icu-version [-v] [-h]"
print "icu_dat_generator.py icu-version [-v|--verbose] [-h|--help]"
def PrintHelp(): print "Usage:" print "icu_dat_generator.py icu-version [-v] [-h]" print "Example:" print "$ANDROID_BUILD_TOP/external/icu4c/stubdata$ ./icu_dat_generator.py 4.2"
command = " ".join(command_list)
command = "[%s] %s" % (working_dir, " ".join(command_list))
def InvokeIcuTool(tool, working_dir, args): command_list = [os.path.join(GetIcuPrebuiltDir(), tool)] command_list.extend(args) if VERBOSE: command = " ".join(command_list) print command ret = subprocess.call(command_list, cwd = working_dir) if ret != 0: sys.exit(command_list[0:])
print "every_locale=" % sorted(every_locale)
every_language = set() for locale in every_locale: language = re.sub(r"(_.*)", "", locale) if len(language) == 2: every_language.add(language) input_basename = os.path.basename(input_file) print "%s includes %s." % (input_basename, ", ".join(sorted(every_language)))
def GenResIndex(input_file): res_index = "res_index.txt" brkitrs = set() colls = set() currs = set() langs = set() locales = set() regions = set() zones = set() for line in open(input_file, "r"): if "root." in line or "res_index" in line or "_.res" in line: continue if "brkitr/" in line: AddResFile(brkitrs, line) eli...
self.Report.cycle = int(data)
try: self.Report.cycle = int(data) except ValueError: self.Report.cycle = 0
def ParseReport(self, MetarReport = None): """Take report with raw info only and return it with in parsed values filled in. Note: This function edits the WeatherReport object you supply!""" if self.Report is None and MetarReport is None: raise EmptyReportException, \ "No report given on init and ParseReport()." elif Me...
elif (header == "Windchill"): f, c = data.split(None, 3)[0:3:2] self.Report.w_chillf = float(f) self.Report.w_chill = float(c[1:])
def ParseReport(self, MetarReport = None): """Take report with raw info only and return it with in parsed values filled in. Note: This function edits the WeatherReport object you supply!""" if self.Report is None and MetarReport is None: raise EmptyReportException, \ "No report given on init and ParseReport()." elif Me...
shutil.rmtree(path) logger.info("Removing %r", path)
if os.path.isdir(path): shutil.rmtree(path) logger.info("Removing %r", path)
def uninstall(name, options): path = options['etc-directory'] shutil.rmtree(path) logger.info("Removing %r", path) directories = () if options['prefix'] != '/': directories = ('crontab', 'rc', 'logrotate') for d in directories + ('log', 'run'): path = options[d+'-directory'] if os.listdir(path): logger.warn("Can't remo...
if options['prefix'] != '/':
if options.get('prefix', '/') != '/':
def uninstall(name, options): path = options['etc-directory'] shutil.rmtree(path) logger.info("Removing %r", path) directories = () if options['prefix'] != '/': directories = ('crontab', 'rc', 'logrotate') for d in directories + ('log', 'run'): path = options[d+'-directory'] if os.listdir(path): logger.warn("Can't remo...
if os.listdir(path): logger.warn("Can't remove non-empty directory %r.", path) else: os.rmdir(path) logger.info("Removing %r.", path)
if os.path.isdir(path): if os.listdir(path): logger.warn("Can't remove non-empty directory %r.", path) else: os.rmdir(path) logger.info("Removing %r.", path)
def uninstall(name, options): path = options['etc-directory'] shutil.rmtree(path) logger.info("Removing %r", path) directories = () if options['prefix'] != '/': directories = ('crontab', 'rc', 'logrotate') for d in directories + ('log', 'run'): path = options[d+'-directory'] if os.listdir(path): logger.warn("Can't remo...
f = tempfile.NamedTemporaryFile(suffix=".attribute",mode="w+")
fd, fname = tempfile.mkstemp(suffix=".attribute") f = os.fdopen(fd,"w+")
def edit_str(self,string): """ Launches a text editor on a tempory file conatinaing string. Returns the contents of the file when the editor is closed. """ f = tempfile.NamedTemporaryFile(suffix=".attribute",mode="w+") f.write(string) f.flush() self.launch_edit(f.name) f.seek(0L) newval = f.readlines() f.close() return...
f.flush() self.launch_edit(f.name) f.seek(0L)
f.close() self.launch_edit(fname) f = open(fname,"r")
def edit_str(self,string): """ Launches a text editor on a tempory file conatinaing string. Returns the contents of the file when the editor is closed. """ f = tempfile.NamedTemporaryFile(suffix=".attribute",mode="w+") f.write(string) f.flush() self.launch_edit(f.name) f.seek(0L) newval = f.readlines() f.close() return...
if not hasattr(bpython.cli.Repl,"closed"): bpython.cli.Repl.closed = closed
repl = None try: repl = bpython.cli.Repl except AttributeError: pass if not repl: repl = bpython.cli.CLIRepl if not hasattr(repl,"closed"): repl.closed = closed
def DoPatches(self): super(BPython,self).DoPatches() #Mercurial 1.4 calls sys.stdout.closed() - this ensures that call exists if not hasattr(bpython.cli.Repl,"closed"): bpython.cli.Repl.closed = closed
bpython.cli.main(args=("--quiet",) ,locals_ = { 'ctx': ctx })
bpython.cli.main(args=["--quiet",] ,locals_ = { 'ctx': ctx })
def Run(self): self.DoPatches()
self.assertEqual(self.plugin_info[0].name,"FirstPlugin")
self.assertTrue("FirstPlugin" in [x.name for x in self.plugin_info])
def loading_check(self): """ Test the plugins load. """ if self.plugin_info is None: # check nb of categories self.assertEqual(len(self.simplePluginManager.getCategories()),1) sole_category = self.simplePluginManager.getCategories()[0] # check the number of plugins self.assertEqual(len(self.simplePluginManager.getPlugi...
def testCreate(self): val=MMAttributeValue(parts = {1:"test",2:"this"})
def testUnderInit(self): val=MMAttributeValue(parts = {"1":"test","2":"this"})
def testCreate(self): val=MMAttributeValue(parts = {1:"test",2:"this"}) self.assertEqual(val.get_raw_rst(),"test\nthis") self.assertEqual(len(val.get_parts()),2)
return open(cls.active[filename].realname)
try: rfile = open(cls.active[filename].realname) except IOError, e: self.logger.debug("%s - Failling back to main file %s"%(e,filename)) rfile = open(filename) return rfile
def open_read(cls,filename): """ Open a file for reading. Normally opens filename - unless it is the process of being updated in which case you get the update file - so you should see the most recent updates sent to the filesystem. """ #With Posix file semantics we don't need to protect the actual reads as # the file h...
if type(obj) is types.InstanceType: return False
def _myCallable(obj): import collections try: #Py3.0 doesn't have callable return isinstance(obj,collections.Callable) except AttributeError: #Py2.5 Doesn't have collections.Callable return callable(obj)
return "\n".join(newval)
return "".join(newval)
def edit_str(self,string): """ Launches a text editor on a tempory file conatinaing string. Returns the contents of the file when the editor is closed. """ #NamedTemporary file works really well on Unix but # is a complete blowout under windows - where there # is no way to unlock the file and *not* delete it fd, fnam...
options.virtualenv.packages_to_install.remove('bpython') options.setup.install_requires.remove('bpython')
try: options.virtualenv.packages_to_install.remove('bpython') except ValueError: pass try: options.setup.install_requires.remove('bpython') except ValueError: pass
def src_environ(options): """Install packages necessary for the installer in the source environment""" print "verifying src environment" try: import virtualenv print "virtual env already here - nothing to do" except ImportError: if int(options.src_environ.get('srcenv_loop',0)) == 1: raise LogicError("Virualenv install ...
subprocess.call(sys.executable , os.path.join(here,"install.py") )
subprocess.call([sys.executable , os.path.join(here,"install.py")])
def install(options): """Create a virtual environment and install into it. You problably want this option as it ensures MysteryMachine doesn't touch your systemwide yapsy install. MysteryMachine currently requires a patched version of ypasy, so installing mysterrymachine virtually means we don't break any existing py...
except WindowsError,OSError:
except (WindowsError,OSError):
def install(options): """Create a virtual environment and install into it. You problably want this option as it ensures MysteryMachine doesn't touch your systemwide yapsy install. MysteryMachine currently requires a patched version of ypasy, so installing mysterrymachine virtually means we don't break any existing py...
subprocess.call(paver,"-f",os.path.join(here,"pavement.py"),"install_here")
subprocess.call([paver,"-f",os.path.join(here,"pavement.py"),"install_here" ])
def install(options): """Create a virtual environment and install into it. You problably want this option as it ensures MysteryMachine doesn't touch your systemwide yapsy install. MysteryMachine currently requires a patched version of ypasy, so installing mysterrymachine virtually means we don't break any existing py...
version = "0.1.1",
version = "0.1.2",
def install(options): """Create a virtual environment and install into it. You problably want this option as it ensures MysteryMachine doesn't touch your systemwide yapsy install. MysteryMachine currently requires a patched version of ypasy, so installing mysterrymachine virtually means we don't break any existing py...
changed = [] for list in self.repo.status(): changed += list
modified, added, removed, deleted, unknown, ignored, clean = self.repo.status() if not kwargs.get("deleted"): deleted = []
def uptodate(self,*args,**kwargs): """ Returns true is repo is uptodate.
return len(changed) == 0
for list in itertools.chain(modified,added,removed): return False return True
def uptodate(self,*args,**kwargs): """ Returns true is repo is uptodate.
self.ui.warn("%slean requested in non-up-todate repo" % (
self.ui.warn("%slean requested in non-up-todate repo." % (
def clean(self,*args,**kwargs): """ Cleans the repo. --force clean runs even if hg is not uptodate. --full deletes everything except the .hg/ . otherwise we just delete files in the hg manifest. """ #Force the main store to remove any tempfiles mysuper = super(HgStoreMixin,self) if hasattr(mysuper,"clean"): mysupe...
_do_test( [ os.curdir ] ) @task def test_installed(): """Run MysteryMachine units tests on the Install MysteryMachine distribution with the default python""" _do_test() def _do_test(path_prefix=[]):
def test(): """Run MysteryMachine unit test on the default python""" path=os.getenv("PYTHONPATH") if path == None: path = os.curdir else: path = path+os.pathsep+os.curdir os.putenv("PYTHONPATH",path) for python in PYTHONS: sys.stderr.write( "Testing under %s:\n" % python ) #TODO: should this inner loop go inside test...
path = os.curdir
path = add_path
def test(): """Run MysteryMachine unit test on the default python""" path=os.getenv("PYTHONPATH") if path == None: path = os.curdir else: path = path+os.pathsep+os.curdir os.putenv("PYTHONPATH",path) for python in PYTHONS: sys.stderr.write( "Testing under %s:\n" % python ) #TODO: should this inner loop go inside test...
path = path+os.pathsep+os.curdir
path = path+os.pathsep+add_path
def test(): """Run MysteryMachine unit test on the default python""" path=os.getenv("PYTHONPATH") if path == None: path = os.curdir else: path = path+os.pathsep+os.curdir os.putenv("PYTHONPATH",path) for python in PYTHONS: sys.stderr.write( "Testing under %s:\n" % python ) #TODO: should this inner loop go inside test...
os.putenv("PYTHONPATH",path)
if path: os.putenv("PYTHONPATH",path)
def test(): """Run MysteryMachine unit test on the default python""" path=os.getenv("PYTHONPATH") if path == None: path = os.curdir else: path = path+os.pathsep+os.curdir os.putenv("PYTHONPATH",path) for python in PYTHONS: sys.stderr.write( "Testing under %s:\n" % python ) #TODO: should this inner loop go inside test...
logging.getLogger("").addHandler(logging.StreamHandler(sys.stderr))
def __init__(self,args): ###DO all initialisation. #Define the logger early so that it is ready for use if not configured. self.logger = logging.getLogger("MysteryMachine") self.cmdline_options,self.args=_parse_options(args)
modlogger.debug("%s %s", str(nodes),str(msg))
def role_handler(role, rawtext, text, lineno, inliner, options={}, content=[] ): msg = [] nodes = [] modlogger.debug( "role handler (%s)" % text) modlogger.debug( "role-options:%s"%str(options)) modlogger.debug( "role-content:%s"%str(content)) mainobj = None if 'systemcntxt' in options: mainobj = options['systemcnt...
categories_filter={"Default":Extension},
categories_filter={"Default":Extension.Extension},
def __init__(self,cfg): if not 'extensions' in cfg: cfg['extensions'] = {'path':[] , 'trusted': [] } self.plugin_man =TrustedPluginManager.TrustedPluginManager( directories_list=cfg['extensions']['path'], plugin_info_ext="mm-plugin", categories_filter={"Default":Extension}, trustList= cfg['extensions']['trusted'] )
return "/course/%s/" % (str(self.db_course.id))
return "/courses/course/%s/" % (str(self.db_course.id))
def api_url(self): return "/course/%s/" % (str(self.db_course.id))
db_search = Offering.objects
db_search = Section.objects
def search(request): d = request.GET db_search = Offering.objects # search by semester # course=cis-120-001 [alternate way oof searching; sem defaults to current?] # description queries = {"dept": "course__department", "name": "course__coursename__icontains", "instructor": "professors__name__icontains", "building": "...
def make_api_section(db_offering): db_course = db_offering.course db_semester = db_offering.semester db_department = db_course.department
def make_api_section(db_section): db_course = db_section.course db_semester = db_course.semester
def make_api_section(db_offering): db_course = db_offering.course db_semester = db_offering.semester db_department = db_course.department
api_department = APIDepartment(api_semester, db_department) api_course = APICourse(api_department, db_course) api_section = APISection(api_course, db_offering)
api_course = APICourse(db_course, api_semester) api_section = APISection(api_course, db_section)
def make_api_section(db_offering): db_course = db_offering.course db_semester = db_offering.semester db_department = db_course.department
print timeTuple
def parseTime(timeTuple, earlyInstructor=False): """ Converts massive tuple that findTimes regexi return into something moderately useful. earlyInstructor is true if instructor's the second item in the tuple, false if 14th. """ # early instructor case for timetable if timetable and timeTuple[6] != '': earlyInstructor ...
if "TBA" == roomCode:
if "TBA" == roomCode or "" == roomCode:
def saveRoom(roomCode): """ Returns a Room given code, creating room and building if necessary """ # This is wrong. if "TBA" == roomCode: roomCode = "TBA 0" (buildCode, roomNum) = roomCode.split(' ') # try finding a building, if nothing, return a new one try: building = Building.objects.filter(code=buildCode)[0] exc...
api_department.add_data([APICourse(api_department, c.course) for c in db_courses])
api_department.add_data([APICourse(c.course, api_semester) for c in db_courses])
def department(request, semester, department): """ display all data for a department (i.e. a list of courses) """ db_semester = Semester(semester) api_semester = APISemester(db_semester) #todo figure out magic case-sensitivity + whitespace trimming db_department = Department.objects.get(code=department) api_department ...
req = 'svn+%s@%s
req = '%s@%s
def from_dist(cls, dist, dependency_links, find_tags=False): location = os.path.normcase(os.path.abspath(dist.location)) comments = [] if vcs.get_backend_name(location): editable = True req = get_src_requirement(dist, location, find_tags) if req is None: logger.warn('Could not determine repository location of %s' % loc...
mkdir('scripts')
folder = 'script_folder' mkdir(folder)
def test_install_using_install_option_and_editable(): """ Test installing a tool using -e and --install-option """ env = reset_env() mkdir('scripts') result = run_pip('install', '-e', '%s#egg=virtualenv' % local_checkout('hg+http://bitbucket.org/ianb/virtualenv'), '--install-option="--install-scripts=scripts"') virtual...
'--install-option="--install-scripts=scripts"') virtualenv_bin = Path('scripts')/'virtualenv'+env.exe assert virtualenv_bin in result.files_created, str(result)
'--install-option=--script-dir=%s' % folder) virtualenv_bin = env.venv/'src'/'virtualenv'/folder/'virtualenv'+env.exe assert virtualenv_bin in result.files_created
def test_install_using_install_option_and_editable(): """ Test installing a tool using -e and --install-option """ env = reset_env() mkdir('scripts') result = run_pip('install', '-e', '%s#egg=virtualenv' % local_checkout('hg+http://bitbucket.org/ianb/virtualenv'), '--install-option="--install-scripts=scripts"') virtual...
if url.startswith('/') or url.startswith('\\'): url = path_to_url(url)
if self._is_file_url_scheme(url): url = path_to_url2(url)
def get_url(self, location): url = call_subprocess( [self.cmd, 'showconfig', 'paths.default'], show_stdout=False, cwd=location).strip() if url.startswith('/') or url.startswith('\\'): url = path_to_url(url) return url.strip()
if repo.startswith(os.path.sep):
if self._is_file_scheme(repo):
def get_url(self, location): urls = call_subprocess( [self.cmd, 'info'], show_stdout=False, cwd=location) for line in urls.splitlines(): line = line.strip() for x in ('checkout of branch: ', 'parent branch: '): if line.startswith(x): repo = line.split(x)[1] if repo.startswith(os.path.sep): return path_to_url2(repo) ret...
call_subprocess(['hg', 'clone', '-q', url, dest])
call_subprocess(['hg', 'clone', '--noupdate', '-q', url, dest])
def obtain(self, dest): url, rev = self.get_url_rev() if rev: rev_options = [rev] rev_display = ' (to revision %s)' % rev else: rev_options = [] rev_display = '' if self.check_destination(dest, url, rev_options, rev_display): logger.notify('Cloning hg %s%s to %s' % (url, rev_display, display_path(dest))) call_subproces...
if resp.code != 200 and scheme not in ('ftp', 'ftps'):
if hasattr(resp, 'code') and resp.code != 200 and scheme not in ('ftp', 'ftps'):
def _get_content_type(url): """Get the Content-Type of the given url, using a HEAD request""" scheme, netloc, path, query, fragment = urlparse.urlsplit(url) if not scheme in ('http', 'https', 'ftp', 'ftps'): ## FIXME: some warning or something? ## assertion error? return '' req = Urllib2HeadRequest(url, headers={'Host'...
return resp.info().getheader('Content-Type') or ''
return resp.info().get('content-type', '')
def _get_content_type(url): """Get the Content-Type of the given url, using a HEAD request""" scheme, netloc, path, query, fragment = urlparse.urlsplit(url) if not scheme in ('http', 'https', 'ftp', 'ftps'): ## FIXME: some warning or something? ## assertion error? return '' req = Urllib2HeadRequest(url, headers={'Host'...
status = '%s %s' % (response.getcode() or 200, getattr(response, 'msg', 'OK'))
status = '%s %s' % (response.code or 200, getattr(response, 'msg', 'OK'))
def _cache_url(self, filepath): response = urlopen_original(self.url) fp = open(filepath, 'wb') # when it uses file:// scheme, code is None and there is no msg attr # but it has been successfully opened status = '%s %s' % (response.getcode() or 200, getattr(response, 'msg', 'OK')) headers = ['%s: %s' % (key, value) for...
status = '%s %s' % (response.code or 200, getattr(response, 'msg', 'OK'))
status = '%s %s' % (getattr(response, 'code', 200), getattr(response, 'msg', 'OK'))
def _cache_url(self, filepath): response = urlopen_original(self.url) fp = open(filepath, 'wb') # when it uses file:// scheme, code is None and there is no msg attr # but it has been successfully opened status = '%s %s' % (response.code or 200, getattr(response, 'msg', 'OK')) headers = ['%s: %s' % (key, value) for key,...
output = run_pip('search', 'pip', expect_error=True)
output = run_pip('search', 'pip')
def test_search(): """ End to end test of search command. """ reset_env() output = run_pip('search', 'pip', expect_error=True) assert 'pip installs packages' in output.stdout
terminal_width = terminal_size[0] else: terminal_width = None
if terminal_size is not None: terminal_width = terminal_size[0]
def run(self, options, args): if not args: print >> sys.stderr, 'ERROR: Missing required argument (search query).' return query = args[0] index_url = options.index
checker = OutputChecker()
def test_freeze(): """ Some tests of freeze, first we have to install some stuff. Note that the test is a little crude at the end because Python 2.5+ adds egg info to the standard library, so stuff like wsgiref will show up in the freezing. (Probably that should be accounted for in pip, but currently it is not). TOD...
assert checker.check_output(expected, str(result), ELLIPSIS), [expected,str(result)]
_check_output(result, expected)
def test_freeze(): """ Some tests of freeze, first we have to install some stuff. Note that the test is a little crude at the end because Python 2.5+ adds egg info to the standard library, so stuff like wsgiref will show up in the freezing. (Probably that should be accounted for in pip, but currently it is not). TOD...
assert checker.check_output(expected, str(result), ELLIPSIS), result
_check_output(result, expected)
def test_freeze(): """ Some tests of freeze, first we have to install some stuff. Note that the test is a little crude at the end because Python 2.5+ adds egg info to the standard library, so stuff like wsgiref will show up in the freezing. (Probably that should be accounted for in pip, but currently it is not). TOD...
checker = OutputChecker()
def test_freeze_git_clone(): """ Test freezing a Git clone. """ env = reset_env() checker = OutputChecker() result = env.run('git', 'clone', 'git://github.com/jezdez/django-pagination.git', 'django-pagination') result = env.run('git', 'checkout', '1df6507872d73ee387eb375428eafbfc253dfcd8', cwd= env.scratch_path/ 'djan...
assert checker.check_output(expected, str(result), ELLIPSIS), result
_check_output(result, expected)
def test_freeze_git_clone(): """ Test freezing a Git clone. """ env = reset_env() checker = OutputChecker() result = env.run('git', 'clone', 'git://github.com/jezdez/django-pagination.git', 'django-pagination') result = env.run('git', 'checkout', '1df6507872d73ee387eb375428eafbfc253dfcd8', cwd= env.scratch_path/ 'djan...
checker = OutputChecker()
def test_freeze_mercurial_clone(): """ Test freezing a Mercurial clone. """ reset_env() env = get_env() checker = OutputChecker() result = env.run('hg', 'clone', '-r', 'f8f7eaf275c5', 'http://bitbucket.org/jezdez/django-dbtemplates/', 'django-dbtemplates') result = env.run('python', 'setup.py', 'develop', cwd=env.scra...
assert checker.check_output(expected, str(result), ELLIPSIS), result
_check_output(result, expected)
def test_freeze_mercurial_clone(): """ Test freezing a Mercurial clone. """ reset_env() env = get_env() checker = OutputChecker() result = env.run('hg', 'clone', '-r', 'f8f7eaf275c5', 'http://bitbucket.org/jezdez/django-dbtemplates/', 'django-dbtemplates') result = env.run('python', 'setup.py', 'develop', cwd=env.scra...
checker = OutputChecker()
def test_freeze_bazaar_clone(): """ Test freezing a Bazaar clone. """ reset_env() env = get_env() checker = OutputChecker() result = env.run('bzr', 'checkout', '-r', '174', 'http://bazaar.launchpad.net/%7Edjango-wikiapp/django-wikiapp/release-0.1/', 'django-wikiapp') result = env.run(os.path.join(env.bin_dir, 'python'...
assert checker.check_output(expected, str(result), ELLIPSIS), result
_check_output(result, expected)
def test_freeze_bazaar_clone(): """ Test freezing a Bazaar clone. """ reset_env() env = get_env() checker = OutputChecker() result = env.run('bzr', 'checkout', '-r', '174', 'http://bazaar.launchpad.net/%7Edjango-wikiapp/django-wikiapp/release-0.1/', 'django-wikiapp') result = env.run(os.path.join(env.bin_dir, 'python'...
data = urllib2.urlopen('http://pypi.python.org/pypi/').read() projects = [m.group(1) for m in re.finditer(r'href="/pypi/([^/"]*)', data)]
data = urllib2.urlopen('http://pypi.python.org/simple/').read() projects = [m.group(1) for m in re.finditer(r'<a.*?>(.+)</a>', data)]
def all_projects(): data = urllib2.urlopen('http://pypi.python.org/pypi/').read() projects = [m.group(1) for m in re.finditer(r'href="/pypi/([^/"]*)', data)] return projects
output = args[0]
output = os.path.abspath(args[0])
def main(args=None): if args is None: args = sys.argv[1:] if not args: print 'Usage: test_all_pip.py <output-dir>' sys.exit(1) output = args[0] if not os.path.exists(output): print 'Creating %s' % output os.makedirs(output) pending_fn = os.path.join(output, 'pending.txt') if not os.path.exists(pending_fn): print 'Downl...
code = subprocess.call([os.path.join(dest_dir, 'bin', 'python'), pip_fn, 'install', package])
code = subprocess.call([os.path.join(dest_dir, 'bin', 'pip'), 'install', package])
def _test_packages(output, pending_fn): package = get_last_item(pending_fn) print 'Testing package %s' % package dest_dir = os.path.join(output, package) print 'Creating virtualenv in %s' % dest_dir code = subprocess.call(['virtualenv', dest_dir]) assert not code, "virtualenv failed" print 'Trying installation of %s' %...
self.unpack_file(source, location, content_type, link)
if os.path.isdir(source): if os.path.isdir(location): shutil.rmtree(location) shutil.copytree(source, location) else: self.unpack_file(source, location, content_type, link)
def unpack_url(self, link, location, only_download=False): if only_download: location = self.download_dir for backend in vcs.backends: if link.scheme in backend.schemes: vcs_backend = backend(link.url) if only_download: vcs_backend.export(location) else: vcs_backend.unpack(location) return temp_dir = tempfile.mkdtemp()...
sort_path(os.path.join(path, item))
sort_path(path)
def sort_path(path): url = path_to_url2(path) if guess_type(url, strict=False)[0] == 'text/html': urls.append(url) else: files.append(url)
def prefix_match(path, prefix): if path == prefix: return True return path.startswith(prefix) and path[len(prefix)] == os.path.sep
def diff_states(start, end, ignore=None): """ Differences two "filesystem states" as represented by dictionaries of FoundFile and FoundDir objects. Returns a dictionary with following keys: ``deleted`` Dictionary of files/directories found only in the start state. ``created`` Dictionary of files/directories found on...
if not any([k.startswith(i) for i in ignore])])
if not any([prefix_match(k, i) for i in ignore])])
def diff_states(start, end, ignore=None): """ Differences two "filesystem states" as represented by dictionaries of FoundFile and FoundDir objects. Returns a dictionary with following keys: ``deleted`` Dictionary of files/directories found only in the start state. ``created`` Dictionary of files/directories found on...
instance._monkey_patch_urllib2()
def setup(cls): instance = cls() instance._monkey_patch_urllib2() instance._create_cache_folder() instance._add_wsgi_intercepts() return instance
def _monkey_patch_urllib2(self): urlopen = urllib2.urlopen def open_and_add_unknown_domains(arg): if isinstance(arg, basestring): self._store_domain(arg) else: self._store_domain(arg.get_full_url()) return urlopen(arg) urllib2.urlopen = open_and_add_unknown_domains
def _monkey_patch_urllib2(self): urlopen = urllib2.urlopen def open_and_add_unknown_domains(arg): if isinstance(arg, basestring): self._store_domain(arg) else: self._store_domain(arg.get_full_url()) return urlopen(arg) urllib2.urlopen = open_and_add_unknown_domains
domain_fp = open(PyPIProxy.DOMAIN_NAMES_FILEPATH) for line in domain_fp: wsgi_intercept.add_wsgi_intercept(line.strip(), 80, PyPIProxy) domain_fp.close()
def _add_wsgi_intercepts(self): """allow wsgi_intercept to work with urllib2 fakes""" install_opener() domain_fp = open(PyPIProxy.DOMAIN_NAMES_FILEPATH) for line in domain_fp: wsgi_intercept.add_wsgi_intercept(line.strip(), 80, PyPIProxy) domain_fp.close()
domain_fp = open(PyPIProxy.DOMAIN_NAMES_FILEPATH, 'w') domain_fp.write('pypi.python.org\n') domain_fp.close() def _store_domain(self, url): r = re.match(r'https?://([^/]+)', url) if not r: return domain_line = r.group(1) + '\n' if domain_line not in self._get_domains_to_be_intercepted(): domain_fp = open(PyPIProxy.DOM...
def _create_cache_folder(self): if not os.path.exists(self.CACHE_PATH): os.mkdir(self.CACHE_PATH) domain_fp = open(PyPIProxy.DOMAIN_NAMES_FILEPATH, 'w') domain_fp.write('pypi.python.org\n') domain_fp.close()
call_subprocess( [self.cmd, 'checkout', '-q', '-f'] + rev_options, cwd=dest)
call_subprocess([self.cmd, 'reset', '--hard', '-q'] + rev_options, cwd=dest)
def update(self, dest, rev_options): call_subprocess([self.cmd, 'fetch', '-q'], cwd=dest) call_subprocess( [self.cmd, 'checkout', '-q', '-f'] + rev_options, cwd=dest)
rev_options = ['master']
rev_options = ['origin/master']
def obtain(self, dest): url, rev = self.get_url_rev() if rev: rev_options = [rev] rev_display = ' (to %s)' % rev else: rev_options = ['master'] rev_display = '' if self.check_destination(dest, url, rev_options, rev_display): logger.notify('Cloning %s%s to %s' % (url, rev_display, display_path(dest))) call_subprocess([s...
print result.stdout
def test_install_subversion_usersite_editable_with_setuptools_fails(): """ Test installing current directory ('.') into usersite using setuptools """ env = reset_env() (env.lib_path/'no-global-site-packages.txt').rm() # this one reenables user_site result = run_pip('install', '--user', '-e', '%s#egg=initools-dev' % lo...
and branches may need origin/ as a prefix""" if rev is None: return rev_options
and branches may need origin/ as a prefix. Returns the SHA1 of the branch or tag if found. """
def check_rev_options(self, rev, dest, rev_options): """Check the revision options before checkout to compensate that tags and branches may need origin/ as a prefix""" if rev is None: # bail and use preset return rev_options revisions = self.get_tag_revs(dest) revisions.update(self.get_branch_revs(dest)) if rev in revi...
if rev in revisions: return [rev]
def check_rev_options(self, rev, dest, rev_options): """Check the revision options before checkout to compensate that tags and branches may need origin/ as a prefix""" if rev is None: # bail and use preset return rev_options revisions = self.get_tag_revs(dest) revisions.update(self.get_branch_revs(dest)) if rev in revi...
if rev not in inverse_revisions: origin_rev = 'origin/%s' % rev if origin_rev in inverse_revisions: rev = inverse_revisions[origin_rev] else: logger.warn("Could not find a tag or branch '%s', assuming commit." % rev) return [rev]
origin_rev = 'origin/%s' % rev if origin_rev in inverse_revisions: return [inverse_revisions[origin_rev]] elif rev in inverse_revisions: return [inverse_revisions[rev]] else: logger.warn("Could not find a tag or branch '%s', assuming commit." % rev) return rev_options
def check_rev_options(self, rev, dest, rev_options): """Check the revision options before checkout to compensate that tags and branches may need origin/ as a prefix""" if rev is None: # bail and use preset return rev_options revisions = self.get_tag_revs(dest) revisions.update(self.get_branch_revs(dest)) if rev in revi...
checked_rev = self.check_rev_options(rev, dest, rev_options) if rev_options != checked_rev: call_subprocess( [self.cmd, 'checkout', '-q'] + checked_rev, cwd=dest)
if rev: rev_options = self.check_rev_options(rev, dest, rev_options) if not self.get_revision(dest).startswith(rev_options[0]): call_subprocess([self.cmd, 'checkout', '-q'] + rev_options, cwd=dest)
def obtain(self, dest): url, rev = self.get_url_rev() if rev: rev_options = [rev] rev_display = ' (to %s)' % rev else: rev_options = ['master'] rev_display = '' if self.check_destination(dest, url, rev_options, rev_display): logger.notify('Cloning %s%s to %s' % (url, rev_display, display_path(dest))) call_subprocess([s...
tmpdir = mkdtemp()
tmpdir = join(mkdtemp(), 'virtualenv')
def test_uninstall_editable_with_source_outside_venv(): """ Test uninstalling editable install from existing source outside the venv. """ tmpdir = mkdtemp() reset_env() env = get_env() result = env.run('hg', 'clone', 'http://bitbucket.org/ianb/virtualenv/', tmpdir) result2 = run_pip('install', '-e', tmpdir) assert (jo...
rev_options = ['origin/master']
rev_options = ['master']
def obtain(self, dest): url, rev = self.get_url_rev() if rev: rev_options = [rev] rev_display = ' (to %s)' % rev else: rev_options = ['origin/master'] rev_display = '' if self.check_destination(dest, url, rev_options, rev_display): logger.notify('Cloning %s%s to %s' % (url, rev_display, display_path(dest))) call_subpro...
call_subprocess( [self.cmd, 'clone', '-q', url, dest]) rev_options = self.check_rev_options(rev, dest, rev_options) call_subprocess( [self.cmd, 'checkout', '-q'] + rev_options, cwd=dest)
call_subprocess([self.cmd, 'clone', '-q', url, dest]) checked_rev = self.check_rev_options(rev, dest, rev_options) if rev_options != checked_rev: call_subprocess( [self.cmd, 'checkout', '-q'] + checked_rev, cwd=dest)
def obtain(self, dest): url, rev = self.get_url_rev() if rev: rev_options = [rev] rev_display = ' (to %s)' % rev else: rev_options = ['origin/master'] rev_display = '' if self.check_destination(dest, url, rev_options, rev_display): logger.notify('Cloning %s%s to %s' % (url, rev_display, display_path(dest))) call_subpro...
if (basename != 'site-packages'
if (basename != 'site-packages' and basename != 'dist-packages'
def list(self, options, args): if args: raise InstallationError( 'You cannot give an argument with --list') for path in sorted(self.paths()): if not os.path.exists(path): continue basename = os.path.basename(path.rstrip(os.path.sep)) if os.path.isfile(path) and zipfile.is_zipfile(path): if os.path.dirname(path) not in ...
else: options.build_dir = os.path.abspath(options.build_dir) options.src_dir = os.path.abspath(options.src_dir)
options.build_dir = os.path.abspath(options.build_dir) options.src_dir = os.path.abspath(options.src_dir)
def run(self, options, args): if not options.build_dir: options.build_dir = build_prefix if not options.src_dir: options.src_dir = src_prefix if options.download_dir: options.no_install = True options.ignore_installed = True else: options.build_dir = os.path.abspath(options.build_dir) options.src_dir = os.path.abspath(...
assert name.startswith(prefix+'/'), (
assert name.startswith(prefix+os.path.sep), (
def _clean_zip_name(self, name, prefix): assert name.startswith(prefix+'/'), ( "name %r doesn't start with prefix %r" % (name, prefix)) name = name[len(prefix)+1:] name = name.replace(os.path.sep, '/') return name
'sys.path.pop(0)' % here.abspath)
'sys.path.pop(0)' % str(here.abspath))
def _use_fake_pypi_server(self): if not os.path.exists(here/'pypiserver'): self._copy_pypiserver_fake_files() if not os.path.exists(here/'wsgi_intercept'): self._copy_wsgi_intercept_files() site_packages = self.root_path / self.site_packages pth = open(os.path.join(site_packages, 'wsgi_intercept_pypi.pth'), 'w') pth.wr...
initools_folder = os.path.join(_get_vcs_folder()) subprocess.call('svnadmin load . < %s' % filename, cwd=initools_folder, shell=True)
initools_folder = os.path.join(_get_vcs_folder(), 'INITools') devnull = open(os.devnull, 'w') dump = open(filename) subprocess.call(['svnadmin', 'load', initools_folder], stdin=dump, stdout=devnull) dump.close() devnull.close()
def _dump_initools_repository(): filename, _ = urllib.urlretrieve('http://bitbucket.org/hltbra/pip-initools-dump/raw/d7a9beef1bbe/initools_colorstudy.dump') initools_folder = os.path.join(_get_vcs_folder())#, 'INITools') subprocess.call('svnadmin load . < %s' % filename, cwd=initools_folder, shell=True)