queuemo 1.27.6__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.
Files changed (56) hide show
  1. queuemo/__init__.py +24 -0
  2. queuemo/__main__.py +14 -0
  3. queuemo/__patch__.py +8 -0
  4. queuemo/cli/__init__.py +8 -0
  5. queuemo/cli/main.py +185 -0
  6. queuemo/cli/single.py +107 -0
  7. queuemo/cli/state.py +104 -0
  8. queuemo/cli/utils.py +26 -0
  9. queuemo/recipes/__init__.py +59 -0
  10. queuemo/recipes/fastview/__init__.py +26 -0
  11. queuemo/recipes/fastview/after.py +21 -0
  12. queuemo/recipes/fastview/before.py +76 -0
  13. queuemo/recipes/fastview/titlepage.py +58 -0
  14. queuemo/recipes/fastview/toc.py +42 -0
  15. queuemo/recipes/logger.py +37 -0
  16. queuemo/recipes/publish/__init__.py +8 -0
  17. queuemo/recipes/publish/main.py +67 -0
  18. queuemo/recipes/result/__init__.py +28 -0
  19. queuemo/recipes/result/abbreviation.py +49 -0
  20. queuemo/recipes/result/after.py +19 -0
  21. queuemo/recipes/result/before.py +204 -0
  22. queuemo/recipes/result/bibliography.py +88 -0
  23. queuemo/recipes/result/chapter.py +41 -0
  24. queuemo/recipes/result/colors.py +30 -0
  25. queuemo/recipes/result/doctextstyle.py +99 -0
  26. queuemo/recipes/result/footnote.py +42 -0
  27. queuemo/recipes/result/imgfig.py +24 -0
  28. queuemo/recipes/result/index.py +41 -0
  29. queuemo/recipes/result/intro.py +75 -0
  30. queuemo/recipes/result/links.py +39 -0
  31. queuemo/recipes/result/magic.py +86 -0
  32. queuemo/recipes/result/main.py +32 -0
  33. queuemo/recipes/result/smarty.py +31 -0
  34. queuemo/recipes/result/textflow.py +77 -0
  35. queuemo/recipes/result/toc.py +44 -0
  36. queuemo/recipes/result/view.py +117 -0
  37. queuemo/recipes/utils.py +71 -0
  38. queuemo/recipes/validation/__init__.py +8 -0
  39. queuemo/recipes/validation/main.py +75 -0
  40. queuemo/runnable.py +418 -0
  41. queuemo/runtime/__init__.py +8 -0
  42. queuemo/runtime/api.py +170 -0
  43. queuemo/runtime/control.py +83 -0
  44. queuemo/runtime/execute.py +60 -0
  45. queuemo/runtime/runtime.py +206 -0
  46. queuemo/runtime/scheduler.py +259 -0
  47. queuemo/runtime/status.py +67 -0
  48. queuemo/utils.py +95 -0
  49. queuemo/worker/__init__.py +8 -0
  50. queuemo/worker/startup.py +185 -0
  51. queuemo-1.27.6.dist-info/METADATA +61 -0
  52. queuemo-1.27.6.dist-info/RECORD +56 -0
  53. queuemo-1.27.6.dist-info/WHEEL +5 -0
  54. queuemo-1.27.6.dist-info/entry_points.txt +4 -0
  55. queuemo-1.27.6.dist-info/licenses/LICENSE +21 -0
  56. queuemo-1.27.6.dist-info/top_level.txt +1 -0
queuemo/__init__.py ADDED
@@ -0,0 +1,24 @@
1
+ #==============================================================================
2
+ # C O P Y R I G H T
3
+ #------------------------------------------------------------------------------
4
+ # Copyright (c) 2019-2023 by Helmut Konrad Schewe. All rights reserved.
5
+ # This file is property of Helmut Konrad Schewe. Any unauthorized copy,
6
+ # use or distribution is an offensive act against international law and may
7
+ # be prosecuted under federal law. Its content is company confidential.
8
+ #==============================================================================
9
+
10
+ import importlib.metadata
11
+ import os
12
+
13
+ import queuemo.__patch__
14
+ from queuemo.runtime.api import RecipeIO
15
+ from queuemo.runtime.scheduler import isrequired
16
+ from queuemo.runtime.scheduler import required
17
+
18
+ __version__ = importlib.metadata.version('queuemo')
19
+
20
+ ROOT = os.path.abspath(os.path.join(os.path.dirname(__file__), '..'))
21
+
22
+ PROCESS = 'queuemo'
23
+
24
+ INTERACTIVE = False # if True, pause on every scheduler step
queuemo/__main__.py ADDED
@@ -0,0 +1,14 @@
1
+ # =============================================================================
2
+ # C O P Y R I G H T
3
+ # -----------------------------------------------------------------------------
4
+ # Copyright (c) 2019-2023 by Helmut Konrad Schewe. All rights reserved.
5
+ # This file is property of Helmut Konrad Schewe. Any unauthorized copy,
6
+ # use or distribution is an offensive act against international law and may
7
+ # be prosecuted under federal law. Its content is company confidential.
8
+ # =============================================================================
9
+ """Evaluate cmd-args and execute commands"""
10
+
11
+ import queuemo.cli.main
12
+
13
+ if __name__ == "__main__":
14
+ queuemo.cli.main.main()
queuemo/__patch__.py ADDED
@@ -0,0 +1,8 @@
1
+ # =============================================================================
2
+ # C O P Y R I G H T
3
+ # -----------------------------------------------------------------------------
4
+ # Copyright (c) 2020-2023 by Helmut Konrad Schewe. All rights reserved.
5
+ # This file is property of Helmut Konrad Schewe. Any unauthorized copy,
6
+ # use or distribution is an offensive act against international law and may
7
+ # be prosecuted under federal law. Its content is company confidential.
8
+ # =============================================================================
@@ -0,0 +1,8 @@
1
+ # =============================================================================
2
+ # C O P Y R I G H T
3
+ # -----------------------------------------------------------------------------
4
+ # Copyright (c) 2022-2023 by Helmut Konrad Schewe. All rights reserved.
5
+ # This file is property of Helmut Konrad Schewe. Any unauthorized copy,
6
+ # use or distribution is an offensive act against international law and may
7
+ # be prosecuted under federal law. Its content is company confidential.
8
+ # =============================================================================
queuemo/cli/main.py ADDED
@@ -0,0 +1,185 @@
1
+ # =============================================================================
2
+ # C O P Y R I G H T
3
+ # -----------------------------------------------------------------------------
4
+ # Copyright (c) 2019-2023 by Helmut Konrad Schewe. All rights reserved.
5
+ # This file is property of Helmut Konrad Schewe. Any unauthorized copy,
6
+ # use or distribution is an offensive act against international law and may
7
+ # be prosecuted under federal law. Its content is company confidential.
8
+ # =============================================================================
9
+
10
+ import collections
11
+
12
+ import configos
13
+ import qvlink
14
+ import serializeraw
15
+ import utilo
16
+ import utilo.cli
17
+
18
+ import queuemo
19
+ import queuemo.cli.utils
20
+ import queuemo.runnable
21
+
22
+ RUNTIME = 'runtime'
23
+ WAITING = 'waiting'
24
+ JOBS = 'jobs'
25
+ VERBOSE = 'verbose'
26
+ INTERACTIVE = 'interactive'
27
+
28
+ Config = collections.namedtuple(
29
+ 'Config',
30
+ ('interactive failfast showdebug clean runtime waiting '
31
+ 'jobs verbose http skip_unsupported webconfig'),
32
+ )
33
+
34
+
35
+ @utilo.saveme
36
+ def main():
37
+ config = evaluate_cli()
38
+ if config == utilo.INVALID_COMMAND:
39
+ return utilo.INVALID_COMMAND
40
+ # run showdebug
41
+ if config.showdebug:
42
+ return showdebug()
43
+ configure(config)
44
+ closed = worker_startup(config)
45
+ return closed
46
+
47
+
48
+ def configure(config: Config):
49
+ queuemo.INTERACTIVE = config.interactive
50
+ queuemo.cli.utils.logger_start()
51
+ if config.interactive:
52
+ utilo.log('use interactive mode')
53
+ if not utilo.testing():
54
+ # ensure that all test directories are created
55
+ configos.makedirs()
56
+ # check startup
57
+ configos.check_startup()
58
+ if config.clean:
59
+ # remove outdated maybe failed jobs
60
+ qvlink.remove_outdated()
61
+ # run http interface if required
62
+ if config.http:
63
+ http_startup()
64
+
65
+
66
+ def worker_startup(config: Config):
67
+ # start scheduler
68
+ import queuemo.worker.startup # pylint:disable=W0621,C0415
69
+ closed = queuemo.worker.startup.run(
70
+ failfast=config.failfast,
71
+ jobs=config.jobs,
72
+ runtime=config.runtime,
73
+ skip_unsupported=config.skip_unsupported,
74
+ verbose=config.verbose,
75
+ waiting=config.waiting,
76
+ webconfig=config.webconfig,
77
+ )
78
+ return closed
79
+
80
+
81
+ def http_startup():
82
+ # lower queuemo start time, flask requires a second of init time
83
+ import queuemo.runtime.control # pylint:disable=W0621,C0415
84
+ queuemo.runtime.control.start()
85
+
86
+
87
+ CMDS = [
88
+ utilo.Parameter(
89
+ longcut=RUNTIME,
90
+ message='runtime in ticks',
91
+ args={
92
+ 'default': 100,
93
+ },
94
+ ),
95
+ utilo.Parameter(
96
+ longcut=WAITING,
97
+ message='time to wait for the next job in miliseconds',
98
+ args={
99
+ 'default': 1000,
100
+ },
101
+ ),
102
+ utilo.Parameter(
103
+ longcut=JOBS,
104
+ message='maximal number of executed jobs',
105
+ args={
106
+ 'default': 1000,
107
+ },
108
+ ),
109
+ utilo.Flag(
110
+ longcut=INTERACTIVE,
111
+ message='pause on every recipe step and ask to continue',
112
+ ),
113
+ utilo.Flag(
114
+ longcut='failfast',
115
+ message='fail on first error',
116
+ ),
117
+ utilo.Flag(
118
+ longcut='http',
119
+ message='start http interface',
120
+ ),
121
+ utilo.Flag(
122
+ longcut='showdebug',
123
+ message='show list of installed runnable and return',
124
+ ),
125
+ utilo.Flag(
126
+ longcut='clean',
127
+ message='clean outdated jobs',
128
+ ),
129
+ utilo.Flag(
130
+ longcut='skip_unsupported',
131
+ message='do not analyze not supported documents',
132
+ ),
133
+ utilo.Parameter(
134
+ longcut='webconfig',
135
+ message='select msgids of published findings',
136
+ ),
137
+ ]
138
+
139
+
140
+ def evaluate_cli() -> Config:
141
+ parser = utilo.cli.create_parser(
142
+ todo=CMDS,
143
+ config=utilo.ParserConfiguration(
144
+ waitingflag=False,
145
+ cacheflag=False,
146
+ pages=False,
147
+ ),
148
+ prog=queuemo.PROCESS,
149
+ version=queuemo.__version__,
150
+ )
151
+ args = utilo.parse(parser)
152
+ try:
153
+ webconfig = args.get('webconfig', None)
154
+ if webconfig:
155
+ if not utilo.exists(webconfig):
156
+ utilo.error(f'webconfig does not exists: {webconfig}')
157
+ return utilo.INVALID_COMMAND
158
+ utilo.debug(f'use webconfig: {webconfig}')
159
+ webconfig = serializeraw.load_webconfig(webconfig)
160
+ config = Config(
161
+ args[INTERACTIVE],
162
+ args.get('failfast', False),
163
+ args.get('showdebug', False),
164
+ args.get('clean', False),
165
+ int(args[RUNTIME]),
166
+ int(args[WAITING]),
167
+ int(args[JOBS]),
168
+ int(args[VERBOSE]) if args[VERBOSE] else 0,
169
+ args.get('http', False),
170
+ args.get('skip_unsupported', False),
171
+ webconfig=webconfig,
172
+ )
173
+ except ValueError:
174
+ msg = (f'invalid start parameter: `{args[RUNTIME]}`, `{args[WAITING]}`,'
175
+ f' `{args[VERBOSE]}`, `{args[JOBS]}`')
176
+ utilo.error(args)
177
+ utilo.error(msg)
178
+ return utilo.INVALID_COMMAND
179
+ utilo.level_setup(config.verbose)
180
+ return config
181
+
182
+
183
+ def showdebug():
184
+ queuemo.runnable.check()
185
+ return utilo.SUCCESS
queuemo/cli/single.py ADDED
@@ -0,0 +1,107 @@
1
+ # =============================================================================
2
+ # C O P Y R I G H T
3
+ # -----------------------------------------------------------------------------
4
+ # Copyright (c) 2020-2023 by Helmut Konrad Schewe. All rights reserved.
5
+ # This file is property of Helmut Konrad Schewe. Any unauthorized copy,
6
+ # use or distribution is an offensive act against international law and may
7
+ # be prosecuted under federal law. Its content is company confidential.
8
+ # =============================================================================
9
+ """Run queuemo for selected pdf file."""
10
+
11
+ import os
12
+
13
+ import configos
14
+ import qvlink
15
+ import utilo
16
+ import utilo.cli
17
+ import utilo.logger
18
+
19
+ import queuemo
20
+ import queuemo.cli.utils
21
+ import queuemo.runtime.api
22
+ import queuemo.runtime.execute
23
+ import queuemo.worker.startup
24
+
25
+ COMMANDS = [
26
+ utilo.Flag(longcut='create'),
27
+ ]
28
+ DESCRIPTION = """\
29
+ Run queuemo recipe for given -i input and write to -o folder.
30
+ """
31
+
32
+
33
+ @utilo.saveme
34
+ def main() -> int:
35
+ inpath, outpath, verbose, create = eval_cli()
36
+ utilo.logger.level_setup(utilo.Level(verbose))
37
+ queuemo.cli.utils.logger_start()
38
+ if os.path.isfile(inpath):
39
+ if create:
40
+ inpath = create_todo(inpath, outpath)
41
+ if inpath == utilo.FAILURE:
42
+ return utilo.FAILURE
43
+ else:
44
+ utilo.error(f'require directory: {inpath} or use --create flag')
45
+ return utilo.INVALID_COMMAND
46
+ outpath = inpath
47
+ utilo.log(f'write result to: {outpath}')
48
+ # patch todo outpath path. TODO: INVESTIGATE HERE?
49
+ todopath = os.path.normpath(os.path.join(inpath, os.path.pardir))
50
+ configos.todo = lambda _=False: todopath
51
+ configos.ready = lambda _=False: todopath
52
+ # analyze single document
53
+ tmpdir = utilo.tmpdir(configos.tmp())
54
+ jobid = queuemo.worker.startup.jobid(inpath)
55
+ queuemo.runtime.execute.run_document(
56
+ workspace=tmpdir,
57
+ documentid=jobid,
58
+ outpath=outpath,
59
+ config=queuemo.runtime.api.RecipeConfig(verbose=verbose),
60
+ )
61
+ return utilo.SUCCESS
62
+
63
+
64
+ def eval_cli() -> tuple:
65
+ parser = utilo.cli.create_parser(
66
+ description=DESCRIPTION,
67
+ todo=COMMANDS,
68
+ config=utilo.ParserConfiguration(
69
+ inputparameter=True,
70
+ outputparameter=True,
71
+ ),
72
+ prog='queuemo_single',
73
+ version=queuemo.__version__,
74
+ )
75
+ args = utilo.parse(parser)
76
+ inpath, outpath, verbose = utilo.sources( # pylint:disable=W0632
77
+ args,
78
+ singleinput=True,
79
+ use_cwd=False,
80
+ verbose=True,
81
+ )
82
+ inpath = inpath[0]
83
+ create = args.get('create', False)
84
+ return inpath, outpath, verbose, create
85
+
86
+
87
+ def create_todo(inpath, outpath):
88
+ filename = str(os.path.split(inpath)[1])
89
+ if outpath:
90
+ outpath, outname = os.path.split(outpath)
91
+ else:
92
+ outpath = os.getcwd()
93
+ # remove file name
94
+ outname = filename.replace('.pdf', '')
95
+ try:
96
+ outpath = qvlink.create_todo(
97
+ file=inpath,
98
+ filename=filename,
99
+ todoname=outname,
100
+ todopath=outpath,
101
+ exist_ok=True,
102
+ )
103
+ except OSError:
104
+ utilo.error(f'{os.path.join(outpath, outname)} already exists')
105
+ return utilo.FAILURE
106
+ utilo.log(f'create job description in {outpath}')
107
+ return outpath
queuemo/cli/state.py ADDED
@@ -0,0 +1,104 @@
1
+ # =============================================================================
2
+ # C O P Y R I G H T
3
+ # -----------------------------------------------------------------------------
4
+ # Copyright (c) 2022-2023 by Helmut Konrad Schewe. All rights reserved.
5
+ # This file is property of Helmut Konrad Schewe. Any unauthorized copy,
6
+ # use or distribution is an offensive act against international law and may
7
+ # be prosecuted under federal law. Its content is company confidential.
8
+ # =============================================================================
9
+
10
+ import argparse
11
+ import sys
12
+
13
+ import configos
14
+ import qvlink
15
+ import utilo
16
+
17
+
18
+ @utilo.saveme
19
+ def main() -> int:
20
+ action = eval_cli()
21
+ if action.kill:
22
+ kill(action.kill)
23
+ return utilo.SUCCESS
24
+ utilo.log('verify state ...')
25
+ utilo.log(f' todo: {configos.todo()}')
26
+ print_running()
27
+ print_waiting()
28
+ return utilo.SUCCESS
29
+
30
+
31
+ def print_running():
32
+ print_documents(qvlink.State.RUNNING)
33
+
34
+
35
+ def print_waiting():
36
+ print_documents(qvlink.State.WAITING)
37
+
38
+
39
+ def print_documents(state):
40
+ # TODO: PASS READY AND TODO TO AVOID REQUIRED COMMON PARENT
41
+ common = utilo.path_parent(configos.ready())
42
+ documents = qvlink.load_documents(
43
+ common=common,
44
+ owner=None,
45
+ state=state,
46
+ )
47
+ if not documents:
48
+ utilo.log(f'no {state.name} documents')
49
+ return
50
+ utilo.log(f'\n{state.name} documents({len(documents)}):')
51
+ for document in documents:
52
+ print_document(document)
53
+
54
+
55
+ def print_document(document):
56
+ pages = str(document.get('pages')).zfill(3)
57
+ title = document.get('title')
58
+ date = document.get('date')
59
+ name = document.get('name')
60
+ utilo.log(f' - {name} {date} {pages} {title}')
61
+
62
+
63
+ def kill(documentid: str):
64
+ if documentid == 'all':
65
+ todos = collect_all()
66
+ if not todos:
67
+ utilo.error('nothing to kill')
68
+ sys.exit(utilo.INVALID_COMMAND)
69
+ for jobinfo in todos:
70
+ kill(jobinfo.name)
71
+ return
72
+ if not qvlink.document(documentid=documentid):
73
+ utilo.exitx(f'invalid documentid: {documentid}', utilo.INVALID_COMMAND)
74
+ if qvlink.deleted(documentid):
75
+ utilo.exitx(f'already deleted: {documentid}', utilo.INVALID_COMMAND)
76
+ return
77
+ if qvlink.delete(documentid):
78
+ utilo.log(f'killed: {documentid}')
79
+ return
80
+ utilo.error(f'could not kill: {documentid}')
81
+ sys.exit(utilo.INVALID_COMMAND)
82
+
83
+
84
+ def collect_all() -> list:
85
+ todos = qvlink.collect_jobs()[0]
86
+ result = []
87
+ for todo in todos:
88
+ process = qvlink.current(todo.documentid)
89
+ current: qvlink.State = qvlink.State.fromstate(process)
90
+ if current not in (qvlink.State.WAITING, qvlink.State.RUNNING):
91
+ continue
92
+ result.append(todo)
93
+ return result
94
+
95
+
96
+ def eval_cli():
97
+ parser = argparse.ArgumentParser(prog='queuemo_state',)
98
+ parser.add_argument(
99
+ '--kill',
100
+ nargs='?',
101
+ help='stop single job, use all to stop all pending jobs',
102
+ )
103
+ result = parser.parse_args()
104
+ return result
queuemo/cli/utils.py ADDED
@@ -0,0 +1,26 @@
1
+ # =============================================================================
2
+ # C O P Y R I G H T
3
+ # -----------------------------------------------------------------------------
4
+ # Copyright (c) 2022-2023 by Helmut Konrad Schewe. All rights reserved.
5
+ # This file is property of Helmut Konrad Schewe. Any unauthorized copy,
6
+ # use or distribution is an offensive act against international law and may
7
+ # be prosecuted under federal law. Its content is company confidential.
8
+ # =============================================================================
9
+
10
+ import os
11
+
12
+ import configos
13
+ import utilo.logger
14
+
15
+
16
+ def logger_start():
17
+ tmp = configos.tmp()
18
+ os.makedirs(tmp, exist_ok=True)
19
+ # create log folder
20
+ queuemo_tmp = os.path.join(tmp, 'queuemo/log/')
21
+ os.makedirs(queuemo_tmp, exist_ok=True)
22
+ # determine current file name
23
+ logfile = f'{utilo.filetime()}_{utilo.tmpname(10)}.log'
24
+ outpath = os.path.join(queuemo_tmp, logfile)
25
+ utilo.debug(f'write global log to {outpath}')
26
+ utilo.outfile_setup(outpath)
@@ -0,0 +1,59 @@
1
+ # =============================================================================
2
+ # C O P Y R I G H T
3
+ # -----------------------------------------------------------------------------
4
+ # Copyright (c) 2020-2023 by Helmut Konrad Schewe. All rights reserved.
5
+ # This file is property of Helmut Konrad Schewe. Any unauthorized copy,
6
+ # use or distribution is an offensive act against international law and may
7
+ # be prosecuted under federal law. Its content is company confidential.
8
+ # =============================================================================
9
+ """Composition of recipes
10
+ ======================
11
+
12
+ .. note :: outdated approach, TODO: UPDATE
13
+
14
+ DataMining: PDF ->
15
+ RawMaker -> text.yaml ->
16
+ GroupMe -> chapter.yaml ->
17
+
18
+ Analysis/Reporting:
19
+
20
+ Statistica -> statistic.yaml ->
21
+
22
+ Decider:
23
+
24
+ MathStyle -> style.yaml WordStyle
25
+
26
+ Feedback:
27
+
28
+ Feedback -> feedback.yaml Feedback
29
+
30
+ Presentation:
31
+
32
+ HTML VIEW
33
+ """
34
+
35
+ import utilo
36
+
37
+ import queuemo
38
+ import queuemo.runtime.scheduler
39
+
40
+ RECIPES = utilo.join(queuemo.ROOT, 'queuemo', 'recipes', exist=True)
41
+
42
+
43
+ def create(name: str):
44
+ path = utilo.join(RECIPES, name, exist=True)
45
+ loaded = queuemo.runtime.scheduler.load(path)
46
+ return loaded
47
+
48
+
49
+ VALIDATION = create('validation')
50
+ FASTVIEW = create('fastview')
51
+ RESULT = create('result')
52
+ PUBLISH = create('publish')
53
+
54
+ ORDER = [
55
+ VALIDATION,
56
+ FASTVIEW,
57
+ RESULT,
58
+ PUBLISH,
59
+ ]
@@ -0,0 +1,26 @@
1
+ # =============================================================================
2
+ # C O P Y R I G H T
3
+ # -----------------------------------------------------------------------------
4
+ # Copyright (c) 2020-2023 by Helmut Konrad Schewe. All rights reserved.
5
+ # This file is property of Helmut Konrad Schewe. Any unauthorized copy,
6
+ # use or distribution is an offensive act against international law and may
7
+ # be prosecuted under federal law. Its content is company confidential.
8
+ # =============================================================================
9
+ """The fast view aims to produce very fast results to avoid that a user
10
+ leaves the page cause of long waiting time.
11
+
12
+ Requirements:
13
+
14
+ * The first result must be reached in lower than **five seconds**.
15
+ * A complete fast view must be produced in lower than **thirty seconds**.
16
+
17
+ What can be archived very fast?
18
+
19
+ * Title Page Analysis
20
+ * Table of Content Analysis
21
+ * (?)Border Violation
22
+ * (?)Font Analysis
23
+
24
+ How does the fast view work?
25
+ ----------------------------
26
+ """
@@ -0,0 +1,21 @@
1
+ # =============================================================================
2
+ # C O P Y R I G H T
3
+ # -----------------------------------------------------------------------------
4
+ # Copyright (c) 2020-2023 by Helmut Konrad Schewe. All rights reserved.
5
+ # This file is property of Helmut Konrad Schewe. Any unauthorized copy,
6
+ # use or distribution is an offensive act against international law and may
7
+ # be prosecuted under federal law. Its content is company confidential.
8
+ # =============================================================================
9
+
10
+ import qvlink
11
+
12
+ import queuemo
13
+ import queuemo.runtime.api
14
+
15
+
16
+ @queuemo.required
17
+ def run(flow: queuemo.runtime.api.RecipeIO) -> list:
18
+ """Create a file named close to signal update hander that process is
19
+ completed."""
20
+ # TODO: ADD STATUS INFORMATION LATER
21
+ qvlink.finish_fastview(flow.document)
@@ -0,0 +1,76 @@
1
+ # =============================================================================
2
+ # C O P Y R I G H T
3
+ # -----------------------------------------------------------------------------
4
+ # Copyright (c) 2020-2023 by Helmut Konrad Schewe. All rights reserved.
5
+ # This file is property of Helmut Konrad Schewe. Any unauthorized copy,
6
+ # use or distribution is an offensive act against international law and may
7
+ # be prosecuted under federal law. Its content is company confidential.
8
+ # =============================================================================
9
+
10
+ import configos
11
+ import qvlink
12
+ import utilo
13
+
14
+ import queuemo
15
+ import queuemo.recipes.utils
16
+ import queuemo.runnable
17
+ import queuemo.runtime.api
18
+
19
+ TIMEOUT_FASTVIEW_TABLERO = configos.HV_INT_PLUS(default=60)
20
+
21
+ FIRST_PAGES = configos.HV_STR(default='0:10')
22
+
23
+
24
+ @queuemo.required
25
+ def before(flow: queuemo.runtime.api.RecipeIO):
26
+ qvlink.start_analysis(flow.document)
27
+
28
+
29
+ @queuemo.required
30
+ def run(flow: queuemo.runtime.api.RecipeIO) -> list:
31
+ unpack_pdf(flow)
32
+
33
+ queuemo.recipes.utils.determine_sections(flow, pages='0:20')
34
+
35
+ # TODO: DO WE REQUIRE TABLES FOR FIRST 10 PAGES?
36
+ # queuemo.runnable.groupme(
37
+ # inpath=flow.tmppath,
38
+ # outpath=flow.tmppath,
39
+ # pagenumbers=True,
40
+ # footer=True,
41
+ # content=True,
42
+ # )
43
+ # queuemo.runnable.tablero(
44
+ # inpath=flow.tmppath,
45
+ # outpath=flow.tmppath,
46
+ # table=flow.sourcepath,
47
+ # timeout=TIMEOUT_FASTVIEW_TABLERO.value,
48
+ # pages=FIRST_PAGES.value,
49
+ # )
50
+
51
+
52
+ def unpack_pdf(flow: queuemo.runtime.api.RecipeIO):
53
+ pdf = flow.sourcepath
54
+ with utilo.GeorgFork(process=False) as runtime:
55
+ runtime.fork(
56
+ queuemo.runnable.rawmaker,
57
+ inpath=pdf,
58
+ outpath=flow.tmppath,
59
+ all=True,
60
+ images=False,
61
+ figures=False,
62
+ pages=FIRST_PAGES,
63
+ )
64
+ runtime.fork(
65
+ queuemo.runnable.rawmaker,
66
+ inpath=pdf,
67
+ outpath=flow.tmppath,
68
+ prefix='oneline',
69
+ boxes_flow=1.0,
70
+ char_margin=100,
71
+ line_margin=0.1,
72
+ text=True,
73
+ fonts=True,
74
+ pages='0:5',
75
+ )
76
+ assert runtime.result == utilo.SUCCESS, 'could not extract pdf'