src/eric7/CodeFormatting/BlackUtilities.py

branch
eric7
changeset 9221
bf71ee032bb4
parent 9214
bd28e56047d7
child 9436
731d146193e2
equal deleted inserted replaced
9220:e9e7eca7efee 9221:bf71ee032bb4
15 15
16 16
17 def getDefaultConfiguration(): 17 def getDefaultConfiguration():
18 """ 18 """
19 Function to generate a default set of configuration parameters. 19 Function to generate a default set of configuration parameters.
20 20
21 @return dictionary containing the default parameters 21 @return dictionary containing the default parameters
22 @rtype dict 22 @rtype dict
23 """ 23 """
24 return { 24 return {
25 "target-version": set(), 25 "target-version": set(),
33 33
34 34
35 def compileRegExp(regexp): 35 def compileRegExp(regexp):
36 """ 36 """
37 Function to compile a given regular expression. 37 Function to compile a given regular expression.
38 38
39 @param regexp regular expression to be compiled 39 @param regexp regular expression to be compiled
40 @type str 40 @type str
41 @return compiled regular expression object 41 @return compiled regular expression object
42 @rtype re.Pattern 42 @rtype re.Pattern
43 """ 43 """
49 49
50 50
51 def validateRegExp(regexp): 51 def validateRegExp(regexp):
52 """ 52 """
53 Function to validate a given regular expression. 53 Function to validate a given regular expression.
54 54
55 @param regexp regular expression to be validated 55 @param regexp regular expression to be validated
56 @type str 56 @type str
57 @return tuple containing a flag indicating validity and an error message 57 @return tuple containing a flag indicating validity and an error message
58 @rtype tuple of (bool, str) 58 @rtype tuple of (bool, str)
59 """ 59 """
63 return True, "" 63 return True, ""
64 except re.error as e: 64 except re.error as e:
65 return ( 65 return (
66 False, 66 False,
67 QCoreApplication.translate( 67 QCoreApplication.translate(
68 "BlackUtilities", 68 "BlackUtilities", "Invalid regular expression: {0}"
69 "Invalid regular expression: {0}" 69 ).format(str(e)),
70 ).format(str(e))
71 ) 70 )
72 except IndexError: 71 except IndexError:
73 return ( 72 return (
74 False, 73 False,
75 QCoreApplication.translate( 74 QCoreApplication.translate(
76 "BlackUtilities", 75 "BlackUtilities", "Invalid regular expression: missing group name"
77 "Invalid regular expression: missing group name" 76 ),
78 )
79 ) 77 )
80 else: 78 else:
81 return ( 79 return (
82 False, 80 False,
83 QCoreApplication.translate( 81 QCoreApplication.translate(
84 "BlackUtilities", 82 "BlackUtilities", "A regular expression must be given."
85 "A regular expression must be given." 83 ),
86 )
87 ) 84 )

eric ide

mercurial