Changeset 787
- Timestamp:
- 08/04/07 14:30:36 (1 year ago)
- Files:
-
- pyrun/trunk/ChangeLog (modified) (1 diff)
- pyrun/trunk/pyrun.py (modified) (13 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
pyrun/trunk/ChangeLog
r783 r787 1 1 ChangeLog 2 2 ~~~~~~~~~ 3 4 0.1.1 5 * By default, print a warning if any of the argv discovery path items dont 6 exist on the file system. -q suppreses the warnings 3 7 4 8 0.1d pyrun/trunk/pyrun.py
r783 r787 5 5 import os, sys, types, re, traceback, inspect, imp, compiler 6 6 7 from os.path import join, dirname, basename, isfile, isdir 7 from os.path import join, dirname, basename, isfile, isdir, exists 8 8 9 9 have_runpy=False … … 244 244 245 245 Note that by default, egg directories and egg archive files are found as 246 top level package paths but the find process will not decends below the level247 of an egg directory. This behaviour can be modified by judicious use of248 `evaluate_packagelocation` and `allow_descent`.246 top level package paths but the find process will not decends below the 247 level of an egg directory. This behaviour can be modified by judicious use 248 of `evaluate_packagelocation` and `allow_descent`. 249 249 250 250 """ … … 313 313 discover package paths OR legitemate python module files. 314 314 315 The results are returned as a 3 element tuple. The first element is the 316 discovered path and the second is a list containing the result of 317 `path_moduleinfo` for any explict references to python module files and 318 the last is the index of the first non option argument with your supplied 319 offset added to it.: 320 321 ``(pathextension, moduleinfos, inonoption)`` 315 The results are returned as a 4 element tuple: The first element is the 316 discovered path; The second is a list containing the result of 317 `path_pkg_moduleinfo` for any explicit references to python module files; 318 The third is the index of the first non option argument with your 319 supplied offset added to it; and the last is a list of each item in args 320 which does not exist on the file system: 321 322 ``(pathextension, moduleinfos, inonoption, doesnotexist)`` 322 323 323 324 See the implementation of `discover_and_run` for a typical usage example. … … 340 341 """ 341 342 343 doesnotexist = [] 342 344 minfos = [] 343 345 pthextend = [] 344 searchpaths = []346 findpaths = [] 345 347 pthset = set([]) 346 348 … … 349 351 for ia, a in enumerate_argv_args(args, offset): 350 352 351 #minfo = path_moduleinfo(a) 353 if not exists(a): 354 doesnotexist.append(a) 355 352 356 minfo = path_pkg_moduleinfo(a) 353 357 if minfo: … … 355 359 a = minfo[0] 356 360 357 # Currently ~/xxx/foo.py will put ~/xxx in the path ir espective361 # Currently ~/xxx/foo.py will put ~/xxx in the path irrespective 358 362 # of whether there is a ~/xxx/__init__.py. I am very tempted 359 363 # to reject directories which are not discovered from genuine … … 363 367 # , with the current implementation, python files collected 364 368 # together in a 'scripts' directory will be able to do sibling 365 # imports ( and hence shadow things for each other) bec uase their369 # imports ( and hence shadow things for each other) because their 366 370 # common parent directory gets put on the path here. 367 371 if a not in pthset: … … 369 373 pthset.add(a) 370 374 else: 371 searchpaths.append(a)375 findpaths.append(a) 372 376 373 377 newpaths = find_package_paths(pth=pthset, 374 * searchpaths378 *findpaths 375 379 ) 376 380 pthextend.extend(newpaths) 377 381 378 return pthextend, minfos, ia + 1 382 return pthextend, minfos, ia + 1, doesnotexist 379 383 380 384 … … 415 419 argv = argv or sys.argv[:] 416 420 417 pthextend, minfos, ia = discover_path(1, *argv)421 pthextend, minfos, ia, doesnotexist = discover_path(1, *argv) 418 422 419 423 # We are running the module, eat the artificial `--` delimiter … … 443 447 init_globals=None, mod_fname=None, mod_loader=None, alter_sys=True): 444 448 """compile `filename` and run the code using runpy._run_module_code.""" 449 445 450 global runpy 446 451 if not have_runpy: … … 477 482 478 483 try: 479 pthextend, minfos, ia = discover_path(1, *argv) 484 pthextend, minfos, ia, doesnotexist = discover_path( 485 1, *argv) 486 487 if not opts.q and doesnotexist: 488 print (''' 489 Warning: your discovery path arguments referenced the following files or 490 directories which do not exist on the file system:''') 491 print '\t' + '\n\t'.join(doesnotexist) 492 480 493 481 494 # If there are no unconsumed arguments: We have already determined … … 522 535 # takes a single argument. 523 536 if len(argv) < ia+1: 524 print ('The `-%s` pyrun option requires a module name'537 print ('The `-%s` pyrun option requires an argument' 525 538 ) % nextopt 526 539 return -1 … … 660 673 661 674 OPTIONS_runex=[ 675 ('-q', dict(default=False, action='store_true', metavar='QUIET', help= 676 """Suppress all warnings about missing paths etc. Useful when you are 677 using speculative paths and are using -p or -P to print the discoverd 678 path.""")), 662 679 663 680 ('-p', dict(default=False, action='store_true', metavar='PRINTPATH', help=