Returns a list of files named 'fname' from 1) System-wide directory (directory-location of this module) 2) Users HOME directory (os.environ['HOME']) 3) Local directory
(fname)
| 380 | |
| 381 | |
| 382 | def get_standard_file(fname): |
| 383 | """Returns a list of files named 'fname' from |
| 384 | 1) System-wide directory (directory-location of this module) |
| 385 | 2) Users HOME directory (os.environ['HOME']) |
| 386 | 3) Local directory |
| 387 | """ |
| 388 | # System-wide file |
| 389 | filenames = [] |
| 390 | try: |
| 391 | f = __file__ |
| 392 | except NameError: |
| 393 | f = sys.argv[0] |
| 394 | sysfile = os.path.join(os.path.split(os.path.abspath(f))[0], |
| 395 | fname) |
| 396 | if os.path.isfile(sysfile): |
| 397 | filenames.append(sysfile) |
| 398 | |
| 399 | # Home directory |
| 400 | # And look for the user config file |
| 401 | try: |
| 402 | f = os.path.expanduser('~') |
| 403 | except KeyError: |
| 404 | pass |
| 405 | else: |
| 406 | user_file = os.path.join(f, fname) |
| 407 | if os.path.isfile(user_file): |
| 408 | filenames.append(user_file) |
| 409 | |
| 410 | # Local file |
| 411 | if os.path.isfile(fname): |
| 412 | filenames.append(os.path.abspath(fname)) |
| 413 | |
| 414 | return filenames |
| 415 | |
| 416 | |
| 417 | def _parse_env_order(base_order, env): |