@@ -34,14 +34,14 @@ def maybe_string(ptr):
34
34
if not ptr :
35
35
return None
36
36
37
- return ffi .string (ptr ).decode (" utf8" , errors = " surrogateescape" )
37
+ return ffi .string (ptr ).decode (' utf8' , errors = ' surrogateescape' )
38
38
39
39
40
- def to_bytes (s , encoding = " utf-8" , errors = " strict" ):
40
+ def to_bytes (s , encoding = ' utf-8' , errors = ' strict' ):
41
41
if s == ffi .NULL or s is None :
42
42
return ffi .NULL
43
43
44
- if hasattr (s , " __fspath__" ):
44
+ if hasattr (s , ' __fspath__' ):
45
45
s = os .fspath (s )
46
46
47
47
if isinstance (s , bytes ):
@@ -51,7 +51,7 @@ def to_bytes(s, encoding="utf-8", errors="strict"):
51
51
52
52
53
53
def to_str (s ):
54
- if hasattr (s , " __fspath__" ):
54
+ if hasattr (s , ' __fspath__' ):
55
55
s = os .fspath (s )
56
56
57
57
if type (s ) is str :
@@ -69,13 +69,13 @@ def ptr_to_bytes(ptr_cdata):
69
69
to a byte buffer containing the address that the pointer refers to.
70
70
"""
71
71
72
- pp = ffi .new (" void **" , ptr_cdata )
72
+ pp = ffi .new (' void **' , ptr_cdata )
73
73
return bytes (ffi .buffer (pp )[:])
74
74
75
75
76
76
@contextlib .contextmanager
77
77
def new_git_strarray ():
78
- strarray = ffi .new (" git_strarray *" )
78
+ strarray = ffi .new (' git_strarray *' )
79
79
yield strarray
80
80
C .git_strarray_dispose (strarray )
81
81
@@ -88,7 +88,7 @@ def strarray_to_strings(arr):
88
88
calling this function.
89
89
"""
90
90
try :
91
- return [ffi .string (arr .strings [i ]).decode (" utf-8" ) for i in range (arr .count )]
91
+ return [ffi .string (arr .strings [i ]).decode (' utf-8' ) for i in range (arr .count )]
92
92
finally :
93
93
C .git_strarray_dispose (arr )
94
94
@@ -120,19 +120,19 @@ def __init__(self, l):
120
120
return
121
121
122
122
if not isinstance (l , (list , tuple )):
123
- raise TypeError (" Value must be a list" )
123
+ raise TypeError (' Value must be a list' )
124
124
125
125
strings = [None ] * len (l )
126
126
for i in range (len (l )):
127
127
li = l [i ]
128
- if not isinstance (li , str ) and not hasattr (li , " __fspath__" ):
129
- raise TypeError (" Value must be a string or PathLike object" )
128
+ if not isinstance (li , str ) and not hasattr (li , ' __fspath__' ):
129
+ raise TypeError (' Value must be a string or PathLike object' )
130
130
131
- strings [i ] = ffi .new (" char []" , to_bytes (li ))
131
+ strings [i ] = ffi .new (' char []' , to_bytes (li ))
132
132
133
- self .__arr = ffi .new (" char *[]" , strings )
133
+ self .__arr = ffi .new (' char *[]' , strings )
134
134
self .__strings = strings
135
- self .__array = ffi .new (" git_strarray *" , [self .__arr , len (strings )])
135
+ self .__array = ffi .new (' git_strarray *' , [self .__arr , len (strings )])
136
136
137
137
def __enter__ (self ):
138
138
return self
0 commit comments