pyDiffTools 0.1.8__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,11 @@
1
+ # from subprocess import call
2
+ __all__ = [
3
+ "check_numbers",
4
+ "command_line",
5
+ "match_spaces",
6
+ "split_conflict",
7
+ "wrap_sentences",
8
+ "rearrange_tex",
9
+ "outline",
10
+ "update_check",
11
+ ]
@@ -0,0 +1,70 @@
1
+ from subprocess import Popen, PIPE
2
+ import os
3
+
4
+ from .command_registry import register_command
5
+
6
+
7
+ @register_command(
8
+ "check numbers in a latex catalog (e.g. of numbered notebook) of items of"
9
+ " the form '\\item[anything number.anything]'",
10
+ help={
11
+ "start": "First number in the range to search",
12
+ "stop": "Last number in the range to search",
13
+ },
14
+ )
15
+ def num(start, stop):
16
+ """Search a range of numbers in notebook list files and report matches."""
17
+
18
+ try:
19
+ start = int(start)
20
+ stop = int(stop)
21
+ except Exception:
22
+ raise ValueError(
23
+ "I didn't understand the arguments" + repr([start, stop])
24
+ )
25
+ for thisnumber in range(start, stop + 1):
26
+ if os.name == "posix":
27
+ result = Popen(
28
+ [r'grep -Rice "%d\." ~/notebook/list*' % thisnumber],
29
+ shell=True,
30
+ stdout=PIPE,
31
+ )
32
+ else:
33
+ try:
34
+ result = Popen(
35
+ [
36
+ r"C:\Program Files\Git\bin\bash.exe",
37
+ "-c",
38
+ r'grep -rice "%d\." ~/notebook/list*' % thisnumber,
39
+ ],
40
+ stdout=PIPE,
41
+ )
42
+ except Exception:
43
+ result = Popen(
44
+ [
45
+ r"C:\Program Files (x86)\Git\bin\bash.exe",
46
+ "-c",
47
+ r'grep -rice "%d\." ~/notebook/list*' % thisnumber,
48
+ ],
49
+ stdout=PIPE,
50
+ )
51
+ matched_already = False
52
+ matched_multiple = False
53
+ full_string = []
54
+ for thisline in result.stdout.readlines():
55
+ if (not thisline.find(":0") > -1) and thisline.find(".tex:") > -1:
56
+ if not matched_already:
57
+ print(thisnumber, " ", end=" ")
58
+ if not thisline.find(":1") > -1:
59
+ matched_already = True
60
+ full_string.append(thisline.strip())
61
+ if matched_already: # more than one match
62
+ print("conflicting files:")
63
+ print("\n".join(full_string))
64
+ matched_multiple = True
65
+ matched_already = True
66
+ if not matched_multiple:
67
+ if matched_already:
68
+ print("single\t\t", full_string[-1][:-2])
69
+ else:
70
+ print(thisnumber, " has no match")