aboutsummaryrefslogtreecommitdiffstats
path: root/cms/util.pxd.in
blob: ea12dab32b9a43bc1dd5512005dc274cabf9a16d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
#from cms.cython_support cimport * #@cy

cdef public object BytesIO
cdef public object datetime
cdef public object dt_timezone

cdef public str UPPERCASE
cdef public str LOWERCASE
cdef public str NUMBERS

cdef ExBool_t isiterable(object obj) except ExBool_val
cdef _Bool findNot(str string, str template, int64_t idx)
cdef _Bool findAny(str string, str template, int64_t idx)
cdef str htmlEscape(str string)
cdef _Bool stringBool(str string, _Bool default)

cdef inline void str2carray(Py_UCS4 *carray, str string, Py_ssize_t arrayLen):
	cdef Py_ssize_t count
	cdef Py_ssize_t i
	if arrayLen > 0:
		count = min(len(string), arrayLen - 1)
		for i in range(count):
			carray[i] = string[i]
		carray[count] = 0

cdef inline str carray2str(const Py_UCS4 *carray, Py_ssize_t arrayLen):
	cdef str ret = ""
	cdef Py_ssize_t i
	cdef Py_UCS4 c
	if arrayLen > 0:
		for i in range(arrayLen - 1):
			c = carray[i]
			if c == 0:
				break
			ret += c
	return ret

cdef class FSHelpers(object):
	cdef str __pathSep
	cdef object __os_stat
	cdef object __os_listdir
	cdef object __stat_S_ISDIR

	cdef str __mkpath(self, tuple path_elements)
	cdef _Bool __exists(self, tuple path_elements)
	cdef _Bool __exists_nonempty(self, tuple path_elements)
	cdef str __read(self, tuple path_elements)
	cdef object __read_int(self, tuple path_elements)
	cdef object __mtime(self, tuple path_elements)
	cdef object __mtime_nofail(self, tuple path_elements)
	cdef list __subdirList(self, tuple path_elements)

cdef public FSHelpers fs
bues.ch cgit interface