mirror of
https://git.launchpad.net/ubuntu-dev-tools
synced 2025-07-27 23:01:29 +00:00
misc.py
This commit is contained in:
parent
1bbedd4ddd
commit
1558b91dde
@ -22,6 +22,8 @@
|
|||||||
#
|
#
|
||||||
# ##################################################################
|
# ##################################################################
|
||||||
|
|
||||||
|
from __future__ import print_function
|
||||||
|
|
||||||
# Modules.
|
# Modules.
|
||||||
import locale
|
import locale
|
||||||
import os
|
import os
|
||||||
@ -66,8 +68,8 @@ def system_distribution_chain():
|
|||||||
break
|
break
|
||||||
_system_distribution_chain.append(parent)
|
_system_distribution_chain.append(parent)
|
||||||
except Exception:
|
except Exception:
|
||||||
print ('Error: Could not determine the parent of the '
|
print(('Error: Could not determine the parent of the '
|
||||||
'distribution %s' % _system_distribution_chain[-1])
|
'distribution %s' % _system_distribution_chain[-1]))
|
||||||
return []
|
return []
|
||||||
|
|
||||||
return _system_distribution_chain
|
return _system_distribution_chain
|
||||||
@ -92,8 +94,8 @@ def host_architecture():
|
|||||||
stderr=PIPE).communicate()[0].split()
|
stderr=PIPE).communicate()[0].split()
|
||||||
|
|
||||||
if not arch or 'not found' in arch[0]:
|
if not arch or 'not found' in arch[0]:
|
||||||
print 'Error: Not running on a Debian based system; could not ' \
|
print('Error: Not running on a Debian based system; could not ' \
|
||||||
'detect its architecture.'
|
'detect its architecture.')
|
||||||
return None
|
return None
|
||||||
|
|
||||||
return arch[0]
|
return arch[0]
|
||||||
@ -106,13 +108,13 @@ def readlist(filename, uniq=True):
|
|||||||
"""
|
"""
|
||||||
|
|
||||||
if not os.path.isfile(filename):
|
if not os.path.isfile(filename):
|
||||||
print 'File "%s" does not exist.' % filename
|
print('File "%s" does not exist.' % filename)
|
||||||
return False
|
return False
|
||||||
|
|
||||||
content = open(filename).read().replace('\n', ' ').replace(',', ' ')
|
content = open(filename).read().replace('\n', ' ').replace(',', ' ')
|
||||||
|
|
||||||
if not content.strip():
|
if not content.strip():
|
||||||
print 'File "%s" is empty.' % filename
|
print('File "%s" is empty.' % filename)
|
||||||
return False
|
return False
|
||||||
|
|
||||||
items = [item for item in content.split() if item]
|
items = [item for item in content.split() if item]
|
||||||
@ -149,8 +151,8 @@ def split_release_pocket(release, default='Release'):
|
|||||||
def require_utf8():
|
def require_utf8():
|
||||||
'''Can be called by programs that only function in UTF-8 locales'''
|
'''Can be called by programs that only function in UTF-8 locales'''
|
||||||
if locale.getpreferredencoding() != 'UTF-8':
|
if locale.getpreferredencoding() != 'UTF-8':
|
||||||
print >> sys.stderr, ("This program only functions in a UTF-8 locale. "
|
print(("This program only functions in a UTF-8 locale. "
|
||||||
"Aborting.")
|
"Aborting."), file=sys.stderr)
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user