Kaydet (Commit) 9d916e76 authored tarafından Suleyman Poyraz's avatar Suleyman Poyraz

string fonksiyonu yerine strutils kullanilacak

üst ba94a323
...@@ -16,9 +16,9 @@ import time ...@@ -16,9 +16,9 @@ import time
import inary.context as ctx import inary.context as ctx
import inary.util as util import inary.util as util
import string from .. import strutils
# lower borks for international locales. What we want is ascii lower. # lower borks for international locales. What we want is ascii lower.
lower_map = str.maketrans(string.ascii_uppercase, string.ascii_lowercase) lower_map = str.maketrans(strutils.ascii_uppercase, strutils.ascii_lowercase)
class Singleton(object): class Singleton(object):
......
...@@ -12,7 +12,7 @@ ...@@ -12,7 +12,7 @@
import os import os
import time import time
import string from . import strutils
import gettext import gettext
__trans = gettext.translation('inary', fallback=True) __trans = gettext.translation('inary', fallback=True)
...@@ -32,7 +32,7 @@ except ImportError: ...@@ -32,7 +32,7 @@ except ImportError:
def is_char_valid(char): def is_char_valid(char):
"""Test if char is valid object path character.""" """Test if char is valid object path character."""
return char in string.ascii_letters + string.digits + "_" return char in strutils.ascii_letters + strutils.digits + "_"
def is_method_missing(exception): def is_method_missing(exception):
"""Tells if exception is about missing method in SCOM script""" """Tells if exception is about missing method in SCOM script"""
......
...@@ -15,6 +15,16 @@ ...@@ -15,6 +15,16 @@
import operator import operator
from functools import reduce from functools import reduce
whitespace = ' \t\n\r\v\f'
ascii_lowercase = 'abcdefghijklmnopqrstuvwxyz'
ascii_uppercase = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'
ascii_letters = ascii_lowercase + ascii_uppercase
digits = '0123456789'
hexdigits = digits + 'abcdef' + 'ABCDEF'
octdigits = '01234567'
punctuation = """!"#$%&'()*+,-./:;<=>?@[\]^_`{|}~"""
printable = digits + ascii_letters + punctuation + whitespace
def every(pred, seq): def every(pred, seq):
return reduce(operator.and_, list(map(pred, seq)), True) return reduce(operator.and_, list(map(pred, seq)), True)
...@@ -86,3 +96,4 @@ def ascii_upper(str): ...@@ -86,3 +96,4 @@ def ascii_upper(str):
"""Ascii only version of string.upper()""" """Ascii only version of string.upper()"""
trans_table = str.maketrans(str.ascii_lowercase, str.ascii_uppercase) trans_table = str.maketrans(str.ascii_lowercase, str.ascii_uppercase)
return str.translate(trans_table) return str.translate(trans_table)
...@@ -19,7 +19,7 @@ import re ...@@ -19,7 +19,7 @@ import re
import sys import sys
import fcntl import fcntl
import shutil import shutil
import string from . import strutils
import struct import struct
import fnmatch import fnmatch
import hashlib import hashlib
...@@ -671,7 +671,7 @@ def parse_package_name_legacy(package_name): ...@@ -671,7 +671,7 @@ def parse_package_name_legacy(package_name):
# We should handle package names like 855resolution # We should handle package names like 855resolution
name = [] name = []
for part in package_name.split("-"): for part in package_name.split("-"):
if name != [] and part[0] in string.digits: if name != [] and part[0] in strutils.digits:
break break
else: else:
name.append(part) name.append(part)
...@@ -697,7 +697,7 @@ def parse_package_name(package_name): ...@@ -697,7 +697,7 @@ def parse_package_name(package_name):
# Arch field cannot start with a digit. If a digit is found, # Arch field cannot start with a digit. If a digit is found,
# the package might have an old format. Raise here to call # the package might have an old format. Raise here to call
# the legacy function. # the legacy function.
if not arch or arch[0] in string.digits: if not arch or arch[0] in strutils.digits:
raise ValueError raise ValueError
except ValueError: except ValueError:
...@@ -742,7 +742,7 @@ def parse_delta_package_name(package_name): ...@@ -742,7 +742,7 @@ def parse_delta_package_name(package_name):
# Arch field cannot start with a digit. If a digit is found, # Arch field cannot start with a digit. If a digit is found,
# the package might have an old format. Raise here to call # the package might have an old format. Raise here to call
# the legacy function. # the legacy function.
if not arch or arch[0] in string.digits: if not arch or arch[0] in strutils.digits:
raise ValueError raise ValueError
except ValueError: except ValueError:
...@@ -768,7 +768,7 @@ def split_package_filename(filename): ...@@ -768,7 +768,7 @@ def split_package_filename(filename):
# Arch field cannot start with a digit. If a digit is found, # Arch field cannot start with a digit. If a digit is found,
# the package might have an old format. # the package might have an old format.
if not arch or arch[0] in string.digits: if not arch or arch[0] in strutils.digits:
raise ValueError raise ValueError
except ValueError: except ValueError:
...@@ -794,7 +794,7 @@ def split_delta_package_filename(filename): ...@@ -794,7 +794,7 @@ def split_delta_package_filename(filename):
# Arch field cannot start with a digit. If a digit is found, # Arch field cannot start with a digit. If a digit is found,
# the package might have an old format. # the package might have an old format.
if not arch or arch[0] in string.digits: if not arch or arch[0] in strutils.digits:
raise ValueError raise ValueError
except ValueError: except ValueError:
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment