-
Notifications
You must be signed in to change notification settings - Fork 9
/
tasks.py
194 lines (178 loc) · 8.32 KB
/
tasks.py
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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
from dl_conan_build_tools.tasks import conan
from invoke import Collection, task
from invoke.tasks import Task
import platform
import os
import pathlib
import xml.etree.ElementTree as ET
samples_list = [
'Annotations/Annotations/',
'Annotations/InkAnnotations/',
'Annotations/LinkAnnotation/',
'Annotations/PolygonAnnotations/',
'Annotations/PolyLineAnnotations/',
'ContentCreation/AddElements/',
'ContentCreation/AddHeaderFooter/',
'ContentCreation/Clips/',
'ContentCreation/CreateBookmarks/',
'ContentCreation/GradientShade/',
'ContentCreation/MakeDocWithCalGrayColorSpace/',
'ContentCreation/MakeDocWithCalRGBColorSpace/',
'ContentCreation/MakeDocWithDeviceNColorSpace/',
'ContentCreation/MakeDocWithICCBasedColorSpace/',
'ContentCreation/MakeDocWithIndexedColorSpace/',
'ContentCreation/MakeDocWithLabColorSpace/',
'ContentCreation/MakeDocWithSeparationColorSpace/',
'ContentCreation/NameTrees/',
'ContentCreation/NumberTrees/',
'ContentCreation/RemoteGoToActions/',
'ContentCreation/WriteNChannelTiff/',
'ContentModification/Action/',
'ContentModification/AddCollection/',
'ContentModification/AddQRCode/',
'ContentModification/ChangeLayerConfiguration/',
'ContentModification/ChangeLinkColors/',
'ContentModification/CreateLayer/',
'ContentModification/ExtendedGraphicStates/',
'ContentModification/FlattenTransparency/',
'ContentModification/LaunchActions/',
'ContentModification/MergePDF/',
'ContentModification/PageLabels/',
'ContentModification/PDFObject/',
'ContentModification/UnderlinesAndHighlights/',
'ContentModification/Watermark/',
'DocumentConversion/ColorConvertDocument/',
'DocumentConversion/ConvertToOffice/',
'DocumentConversion/CreateDocFromXPS/',
'DocumentConversion/Factur-XConverter/',
'DocumentConversion/PDFAConverter/',
'DocumentConversion/PDFXConverter/',
'DocumentConversion/ZUGFeRDConverter/',
'DocumentOptimization/PDFOptimize/',
'Images/DocToImages/',
'Images/DrawSeparations/',
'Images/DrawToBitmap/',
'Images/EPSSeparations/',
'Images/GetSeparatedImages/',
'Images/ImageEmbedICCProfile/',
'Images/ImageExport/',
'Images/ImageExtraction/',
'Images/ImageFromStream/',
'Images/ImageImport/',
'Images/ImageResampling/',
'Images/ImageSoftMask/',
'Images/OutputPreview/',
'Images/RasterizePage/',
'InformationExtraction/ListBookmarks/',
'InformationExtraction/ListInfo/',
'InformationExtraction/ListLayers/',
'InformationExtraction/ListPaths/',
'InformationExtraction/Metadata/',
'OpticalCharacterRecognition/AddTextToDocument/',
'OpticalCharacterRecognition/AddTextToImage/',
'Other/MemoryFileSystem/',
'Other/StreamIO/',
'Security/AddRegexRedaction/',
'Security/Redactions/',
'Text/AddGlyphs/',
'Text/AddUnicodeText/',
'Text/AddVerticalText/',
'Text/ExtractAcroFormFieldData/',
'Text/ExtractCJKTextByPatternMatch/',
'Text/ExtractTextByPatternMatch/',
'Text/ExtractTextByRegion/',
'Text/ExtractTextFromAnnotations/',
'Text/ExtractTextFromMultiRegions/',
'Text/ExtractTextPreservingStyleAndPositionInfo/',
'Text/ListWords/',
'Text/RegexExtractText/',
'Text/RegexTextSearch/',
'Text/TextExtract/'
]
# Given an absolute sample path, modify the csproj to pull
# a different version of the nuget package for testing
def set_nuget_pkg_version(sample=None, package=None):
if package is None:
return
else:
tree = ET.parse(sample.absolute().as_posix())
elem = tree.findall(".//PackageReference")
for entry in elem:
if 'Adobe.PDF.Library' in entry.attrib.get('Include'):
entry.set('Include', package)
break
# Add the SampleInput entry. We already have an object
# in entry_copy just gotta change the values to SampleInput
new_entry = ET.Element('PackageReference')
new_entry.set('Include', 'Adobe.PDF.Library.SampleInput')
new_entry.set('Version', '1.*')
insert_elem = tree.findall(".//ItemGroup")
insert_elem[0].append(new_entry)
tree.write(sample)
@task()
def clean_samples(ctx):
for sample in samples_list:
full_path = os.path.join(os.getcwd(), sample)
with ctx.cd(full_path):
ctx.run('git clean -fdx')
ctx.run('git checkout .')
@task()
def build_samples(ctx, pkg_name='Adobe.PDF.Library.NET'):
"""Builds the .NET6 samples
"""
ctx.run('invoke clean-samples')
for sample in samples_list:
full_path = os.path.join(os.getcwd(), sample)
if 'DrawSeparations' in sample or 'DocToImages' in sample:
continue
if platform.system() == 'Darwin' and ('ConvertToOffice' in sample or 'CreateDocFromXPS' in sample):
print(f'{sample} not available on this OS')
continue
else:
with ctx.cd(full_path):
last_directory = os.path.basename(os.path.dirname(full_path))
full_name = full_path + last_directory + '.csproj'
set_nuget_pkg_version(pathlib.Path(full_name), package=pkg_name)
if platform.system() == 'Darwin':
ctx.run(f'dotnet build '
'--source https://api.nuget.org/v3/index.json '
'--source /Volumes/raid/products/released/APDFL/nuget/DotNET/for_apdfl_18.0.5Plus/approved/current '
'--source /Volumes/raid/products/released/APDFL/nuget/SampleInputFile/for_apdfl_18.0.4Plus/approved/current ')
elif platform.system() == 'Windows':
ctx.run(f'dotnet build '
'--source https://api.nuget.org/v3/index.json '
'--source \\\\ivy\\raid\\products\\released\\APDFL\\nuget\\DotNET\\for_apdfl_18.0.5Plus\\approved\\current '
'--source \\\\ivy\\raid\\products\\released\\APDFL\\nuget\\SampleInputFile\\for_apdfl_18.0.4Plus\\approved\\current ')
else:
ctx.run(f'dotnet build '
'--source https://api.nuget.org/v3/index.json '
'--source /raid/products/released/APDFL/nuget/DotNET/for_apdfl_18.0.5Plus/approved/current '
'--source /raid/products/released/APDFL/nuget/SampleInputFile/for_apdfl_18.0.4Plus/approved/current ')
@task()
def run_samples(ctx):
"""Runs the .NET6 samples
"""
for sample in samples_list:
full_path = os.path.join(os.getcwd(), sample)
if 'DrawSeparations' in sample or 'DocToImages' in sample:
continue
if platform.system() == 'Darwin' and ('ConvertToOffice' in sample or 'CreateDocFromXPS' in sample):
print(f'{sample} not available on this OS')
continue
elif platform.system() == 'Linux' and 'ConvertToOffice' in sample:
continue
else:
with ctx.cd(full_path):
sample_name = os.path.basename(os.path.dirname(full_path))
if 'DrawSeparations' in sample_name:
continue
ctx.run(f'dotnet run --no-build')
tasks = []
tasks.extend([v for v in locals().values() if isinstance(v, Task)])
conan_tasks = Collection()
conan_tasks.add_task(conan.install_config)
conan_tasks.add_task(conan.login)
conan_tasks.add_task(conan.upload_dependencies)
ns = Collection(*tasks)
ns.add_collection(conan_tasks, 'conan')
ns.configure({'run': {'echo': 'true'}})