scan2wiki API Documentation
amazon
Created on 12023-11-16
@author: wf
Amazon
lookup products on amazon web site
Source code in scan/amazon.py
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 |
|
__init__(debug=False)
constructor
Parameters:
Name | Type | Description | Default |
---|---|---|---|
debug |
bool
|
If set to True, pretty-prints the first product div for debugging. |
False
|
Source code in scan/amazon.py
20 21 22 23 24 25 26 27 |
|
extract_amazon_products(soup)
Extracts product information from Amazon product listing HTML content.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
soup |
BeautifulSoup
|
Soup object of HTML content of the Amazon product listing page. |
required |
Returns:
Type | Description |
---|---|
List[Product]
|
List[Product]: A list of extracted product information as Product objects. |
Source code in scan/amazon.py
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 |
|
lookup_products(search_key)
lookup the given search key e.g. ISBN or EAN
Source code in scan/amazon.py
111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 |
|
barcode
Created on 2023-11-16
@author: wf
Barcode
dataclass
Barcode data structure with static methods e.g. e.g. pyzbar barcode decoder wrapper
Source code in scan/barcode.py
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 |
|
decode(image_file_path, debug=False)
staticmethod
Decodes barcodes from the image at the given file path.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
image_file_path |
str
|
The file path of the image to decode. |
required |
debug |
bool
|
If False, suppress debug information of the PIL library. Default is False. |
False
|
Returns:
Type | Description |
---|---|
list[Barcode]: A list of Barcode objects, or an empty list if no barcodes are found. |
Source code in scan/barcode.py
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 |
|
dms
Created on 2021-10-21
@author: wf
see http://diagrams.bitplan.com/render/png/0xe1f1d160.png see http://diagrams.bitplan.com/render/txt/0xe1f1d160.txt
Archive
Bases: JSONAble
an Archive might be a filesystem on a server or a (semantic) mediawiki
Source code in scan/dms.py
664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 |
|
__init__()
Constructor
Source code in scan/dms.py
670 671 672 673 |
|
getFoldersAndDocuments(withOcr=False)
get the folders of this archive
Return
the list of folders and files
Source code in scan/dms.py
704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 |
|
normalizePageTitle(pageTitle)
normalize the given pageTitle
Source code in scan/dms.py
697 698 699 700 701 702 |
|
ArchiveManager
Bases: EntityManager
manager for Archives
Source code in scan/dms.py
816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 |
|
__init__(mode='sql', debug=False)
constructor
Source code in scan/dms.py
821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 |
|
addFilesAndFoldersForArchive(archive=None, withOcr=False, store=False, debug=True)
staticmethod
add Files and folder for the given Archive
Parameters:
Name | Type | Description | Default |
---|---|---|---|
archive(Archive) |
the archive to add files and folder for |
required | |
store(bool) |
True if the result should be stored in the storage |
required | |
debug(bool) |
True if debugging messages should be displayed |
required |
Source code in scan/dms.py
863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 |
|
DMSStorage
Document management system storage configuration
Source code in scan/dms.py
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 195 196 197 198 199 200 201 202 203 204 205 206 |
|
fromCache(em)
staticmethod
initialize the given entity manager from it's cache
Parameters:
Name | Type | Description | Default |
---|---|---|---|
em(EntityManager) |
the entity manager to initialize |
required |
Source code in scan/dms.py
193 194 195 196 197 198 199 200 201 202 203 204 205 206 |
|
getDatetime(fullpath)
staticmethod
get the last modification time
Parameters:
Name | Type | Description | Default |
---|---|---|---|
fullpath(str) |
the path to get the datetime for |
required |
Source code in scan/dms.py
169 170 171 172 173 174 175 176 177 178 179 |
|
getScanDir()
staticmethod
get the scan/watch directory to be used
Returns:
Name | Type | Description |
---|---|---|
str |
the path to the scan directory |
Source code in scan/dms.py
146 147 148 149 150 151 152 153 154 155 156 157 |
|
getSqlDB()
staticmethod
get the SQlite database connection
Source code in scan/dms.py
159 160 161 162 163 164 165 166 167 |
|
getStorageConfig(debug=False, mode='sql')
staticmethod
get the storageConfiguration
Parameters:
Name | Type | Description | Default |
---|---|---|---|
debug(bool) |
if True show debug information |
required | |
mode(str) |
sql or json |
required |
Return
StorageConfig: the storage configuration to be used
Source code in scan/dms.py
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 |
|
getTimeStr(fullpath)
staticmethod
get the last modification time
Parameters:
Name | Type | Description | Default |
---|---|---|---|
fullpath(str) |
the path to get the time string for |
required |
Source code in scan/dms.py
181 182 183 184 185 186 187 188 189 190 191 |
|
Document
Bases: JSONAble
a document consist of one or more files in the filesystem or a wikipage - the name is the pagetitle or the filename without extension
types then has the list of available file types e.g. "pdf,txt" for single page Documents the document is somewhat redundant to the Page concept
Source code in scan/dms.py
209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 |
|
__init__()
construct me
Source code in scan/dms.py
244 245 246 247 248 |
|
fromDict(record)
overwrite the from Dict
Source code in scan/dms.py
250 251 252 253 254 255 |
|
fromFile(folderPath, file, local=False, withOcr=False)
Parameters:
Name | Type | Description | Default |
---|---|---|---|
folderPath(str) |
the directory |
required | |
file(str) |
the file |
required | |
withOcr(bool) |
if true get the OCRText |
required |
Source code in scan/dms.py
257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 |
|
getContent()
get my content
Return
str: the content of the wikipage
Source code in scan/dms.py
367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 |
|
getOcrText()
get the OCR
Source code in scan/dms.py
320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 |
|
getPDFText()
get my PDF Text
Source code in scan/dms.py
290 291 292 293 294 295 296 297 |
|
readTextFromFile(fileName)
read text from the given fileName
Source code in scan/dms.py
299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 |
|
uploadFile(wikiId)
call back
Source code in scan/dms.py
350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 |
|
DocumentManager
Bases: EntityManager
manager for Documents
Source code in scan/dms.py
537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 |
|
__init__(mode='sql', debug=False)
constructor
Source code in scan/dms.py
542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 |
|
Folder
Bases: JSONAble
a Folder might be a filesystem folder or a category in a wiki
Source code in scan/dms.py
404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 |
|
__init__()
Constructor
Source code in scan/dms.py
409 410 411 412 |
|
getDocuments(files, withOcr=False)
get the documents for this folder based on the files from my listdir
Source code in scan/dms.py
507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 |
|
getFileDocuments()
get all documents for the OCRDocument files in this folder
Return
list: the list of documents
Source code in scan/dms.py
496 497 498 499 500 501 502 503 504 505 |
|
getFiles(extension='.pdf')
get all files with the given extension
Parameters:
Name | Type | Description | Default |
---|---|---|---|
extension(str) |
the extension to search for |
required |
Return
list: the files with the given extension
Source code in scan/dms.py
479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 |
|
getFullpath(folderPath, local=False)
staticmethod
get the full path as accessible on my platform
Parameters:
Name | Type | Description | Default |
---|---|---|---|
folderPath(str) |
the path of the folder |
required | |
local(bool) |
True if the path is for a local folder |
required |
Return
str: the full path of the folder
Source code in scan/dms.py
443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 |
|
getPrefix()
classmethod
get the path prefix for this platform (if any)
Return
str: the prefix e.g. /Volumes on Darwin
Source code in scan/dms.py
429 430 431 432 433 434 435 436 437 438 439 440 441 |
|
getRelpath(folderPath)
classmethod
get the relative path as accessible on my platform
Parameters:
Name | Type | Description | Default |
---|---|---|---|
folderPath(str) |
the path of the folder |
required |
Return
str: the relative path of the folder
Source code in scan/dms.py
461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 |
|
refreshDocuments()
refresh the documents in this folder
Source code in scan/dms.py
526 527 528 529 530 531 532 533 534 |
|
FolderManager
Bases: EntityManager
manager for Archives
Source code in scan/dms.py
575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 |
|
__init__(mode='sql', debug=False)
constructor
Source code in scan/dms.py
580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 |
|
getDocumentRecords(archiveName, folderPath)
get the document records
Source code in scan/dms.py
612 613 614 615 616 617 618 619 620 621 622 623 |
|
getFolder(archive, folderPath)
get the folder for the given archive and folderPath
Parameters:
Name | Type | Description | Default |
---|---|---|---|
archive |
the archive |
required | |
folderPath |
str
|
the path of the folder |
required |
Source code in scan/dms.py
625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 |
|
refreshFolder(archive, folderPath)
for the given archive and folderPath
Parameters:
Name | Type | Description | Default |
---|---|---|---|
archive |
the name of the archive |
required | |
folderPath |
the path of the folder |
required |
Source code in scan/dms.py
651 652 653 654 655 656 657 658 659 660 661 |
|
Wiki
Bases: object
Semantic Mediawiki access proxy
Source code in scan/dms.py
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 |
|
checkIniFile(wikiId, save=None)
staticmethod
check the ini file for the given wikiId
Parameters:
Name | Type | Description | Default |
---|---|---|---|
wikiId(str) |
the wiki id of the wiki to check |
required | |
save(bool) |
True if a new ini file should be created e.g. for test purposes if not set save is True if we are running in a public continuous integration environment |
required |
Source code in scan/dms.py
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 |
|
get(wikiId)
staticmethod
get the Wiki Client with the given wikiId
Parameters:
Name | Type | Description | Default |
---|---|---|---|
wikiId |
str
|
the wiki id of the client |
required |
Return
WikiClient: the WikiClient with the given id
Source code in scan/dms.py
53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 |
|
getSMW(wikiId)
staticmethod
get the semantic mediawiki client with the given wikiId
Parameters:
Name | Type | Description | Default |
---|---|---|---|
wikiId |
str
|
the wiki id of the client |
required |
Return
SMWClient: the SMWClient with the given id
Source code in scan/dms.py
38 39 40 41 42 43 44 45 46 47 48 49 50 51 |
|
inPublicCI()
staticmethod
are we running in a public Continuous Integration Environment?
Source code in scan/dms.py
69 70 71 72 73 74 |
|
entity_view
Created on 2023-11-17
@author: wf
EntityManagerView
a view for a given entity manager
Source code in scan/entity_view.py
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 |
|
linkColumn(name, record, formatWith=None, formatTitleWith=None)
replace the column with the given name with a link
Source code in scan/entity_view.py
35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 |
|
setup_view()
set up my view elements
Source code in scan/entity_view.py
29 30 31 32 33 |
|
show(rowHandler=None, lodKeyHandler=None)
show my given entity manager
Source code in scan/entity_view.py
57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 |
|
EntityView
Source code in scan/entity_view.py
12 13 14 15 16 17 |
|
__init__(entity)
Source code in scan/entity_view.py
15 16 17 |
|
folderwatcher
Created on 2021-04-21
see https://stackoverflow.com/a/66110795/1497139
Handler
Bases: PatternMatchingEventHandler
handle changes for a given wildcard pattern
Source code in scan/folderwatcher.py
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 |
|
__init__(callback, patterns, debug=False)
construct me
Parameters:
Name | Type | Description | Default |
---|---|---|---|
callback |
the function to call |
required | |
patterns |
the patterns to trigger on |
required | |
debug(bool) |
if True print debug output |
required |
Source code in scan/folderwatcher.py
66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 |
|
Watcher
watch the given path with the given callback
Source code in scan/folderwatcher.py
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 |
|
__init__(path, patterns=['*.pdf', '*.jpg'], debug=False)
construct me for the given path Args: path(str): the directory to observer patterns(list): a list of wildcard patterns debug(bool): True if debugging should be switched on
Source code in scan/folderwatcher.py
20 21 22 23 24 25 26 27 28 29 30 31 |
|
run(callback, sleepTime=1, limit=sys.maxsize)
run me
Parameters:
Name | Type | Description | Default |
---|---|---|---|
callback(func) |
the function to trigger when a file appears |
required | |
sleepTime(float) |
how often to check for incoming files - default: 1.0 secs |
required | |
limit(float) |
the maximum time to run the server default: unlimited |
required |
Source code in scan/folderwatcher.py
33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 |
|
logger
Created on 2021-11-02
@author: wf
Logger
Bases: object
a logger module
Source code in scan/logger.py
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 |
|
pdf
PDFMiner
PDFMiner.six wrapper to get PDF Text
Source code in scan/pdf.py
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 |
|
product
Created on 2023-11-16
@author: wf
Product
dataclass
Data class representing a product.
Attributes:
Name | Type | Description |
---|---|---|
title |
str
|
The title of the product. |
image_url |
str
|
The URL of the product image. |
price |
str
|
The price of the product. |
asin |
Optional[str]
|
The Amazon Standard Identification Number (ASIN) of the product, which is a unique identifier on Amazon's platform. |
Source code in scan/product.py
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 |
|
as_html(img_size=128)
Returns an HTML representation of the product with an image thumbnail and a link to the product page.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
img_size |
int
|
Size of the image thumbnail. |
128
|
Returns:
Name | Type | Description |
---|---|---|
str |
str
|
HTML string representation of the product. |
Source code in scan/product.py
39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 |
|
Products
Class to handle/manage product instances and make those persistent.
Attributes:
Name | Type | Description |
---|---|---|
store_path |
str
|
The file path where products are stored as JSON. |
products |
List[Product]
|
List of product instances. |
products_by_asin |
Dict[str, Product]
|
Dictionary mapping ASIN to products. |
products_by_gtin |
Dict[str, Product]
|
Dictionary mapping gtin to products. |
Source code in scan/product.py
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 |
|
__init__(store_path=None)
Initialize the Products instance.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
store_path |
str
|
The file path where products are stored as JSON. Defaults to ~/.scan2wiki/products.json. |
None
|
Source code in scan/product.py
73 74 75 76 77 78 79 80 81 82 |
|
add_product(product)
Adds a product to the product list and updates the mappings. If a product with the same ASIN already exists, it updates the existing record.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
product |
Product
|
The product instance to add. |
required |
Source code in scan/product.py
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 |
|
clear()
Clears the current product list and the associated mappings.
Source code in scan/product.py
84 85 86 87 88 89 90 |
|
delete_product(asin)
Delete a product with the given ASIN.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
asin |
str
|
The ASIN of the product to delete. |
required |
Source code in scan/product.py
118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 |
|
get_aggrid_lod()
Generates a list of dictionaries for ag-Grid representation of the products.
Returns:
Type | Description |
---|---|
List[Dict[str, str]]
|
List[Dict[str, str]]: List of product information formatted for ag-Grid. |
Source code in scan/product.py
134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 |
|
load_from_json(filepath=None)
Loads products from a JSON file and updates the current list and mappings.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
filepath |
str
|
The filepath from which to load the JSON data. Defaults to the instance's store_path attribute. |
None
|
Source code in scan/product.py
175 176 177 178 179 180 181 182 183 184 185 186 187 188 |
|
save_to_json(filename=None)
Saves the current list of products to a JSON file.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
filename |
str
|
The filename where to save the JSON data. Defaults to the instance's store_path attribute. |
None
|
Source code in scan/product.py
156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 |
|
profiler
Created on 2021-10-26
@author: wf
Profiler
simple profiler
Source code in scan/profiler.py
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 |
|
__init__(msg, profile=True)
construct me with the given msg and profile active flag
Parameters:
Name | Type | Description | Default |
---|---|---|---|
msg |
str
|
the message to show if profiling is active |
required |
profile |
bool
|
True if messages should be shown |
True
|
Source code in scan/profiler.py
14 15 16 17 18 19 20 21 22 23 |
|
start()
start profiling
Return
str: start message
Source code in scan/profiler.py
25 26 27 28 29 30 31 32 33 34 35 36 |
|
time(extraMsg='')
time the action and print if profile is active
Return
(float,str): time and message for time
Source code in scan/profiler.py
38 39 40 41 42 43 44 45 46 47 48 49 |
|
scan_cmd
Created on 2023-11-14
@author: wf
ScanCmd
Bases: WebserverCmd
Command line for scan2wiki web server
Source code in scan/scan_cmd.py
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 |
|
getArgParser(description, version_msg)
override the default argparser call
Source code in scan/scan_cmd.py
19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 |
|
main(argv=None)
main call
Source code in scan/scan_cmd.py
42 43 44 45 46 47 48 |
|
scan_webserver
Created on 2023-11-14
@author: wf
ScanSolution
Bases: InputWebSolution
the Scan solution
Source code in scan/scan_webserver.py
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 195 196 197 198 199 200 201 202 203 204 205 206 |
|
__init__(webserver, client)
Initialize the solution
Calls the constructor of the base solution Args: webserver (ScanWebServer): The webserver instance associated with this context. client (Client): The client instance this context is associated with.
Source code in scan/scan_webserver.py
115 116 117 118 119 120 121 122 123 124 125 126 |
|
configure_menu()
configure additional non-standard menu entries
Source code in scan/scan_webserver.py
189 190 191 192 193 194 195 |
|
home()
async
provide the main content page
Source code in scan/scan_webserver.py
197 198 199 200 201 202 203 204 205 206 |
|
setup_footer()
async
add handlers for stdout and stderr
Source code in scan/scan_webserver.py
128 129 130 131 132 133 134 135 136 137 |
|
show_archives()
async
show archives
Source code in scan/scan_webserver.py
175 176 177 178 179 180 181 182 183 184 185 186 187 |
|
update_scans()
update the scans grid
Source code in scan/scan_webserver.py
164 165 166 167 168 169 170 171 172 173 |
|
upload(path=None)
async
handle upload requests
Source code in scan/scan_webserver.py
145 146 147 148 149 150 151 152 153 154 155 |
|
ScanWebServer
Bases: InputWebserver
server for Document Management system with option to scan to Semantic Mediawikis
Source code in scan/scan_webserver.py
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 |
|
__init__()
Constructs all the necessary attributes for the WebServer object.
Source code in scan/scan_webserver.py
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 |
|
files(path='.')
show the files in the given path
Parameters:
Name | Type | Description | Default |
---|---|---|---|
path |
str
|
the path to render |
'.'
|
Source code in scan/scan_webserver.py
92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 |
|
get_config()
classmethod
get the configuration for this Webserver
Source code in scan/scan_webserver.py
35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 |
|
scans
Created on 2023-11-14
@author: wf
Scans
Class to handle operations related to scanned files.
Source code in scan/scans.py
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 |
|
__init__(scandir)
Initialize the Scans object.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
scandir |
str
|
The directory where the scanned files are located. |
required |
Source code in scan/scans.py
19 20 21 22 23 24 25 26 |
|
delete(path)
Parameters:
Name | Type | Description | Default |
---|---|---|---|
path |
str
|
the file to delete |
required |
Source code in scan/scans.py
88 89 90 91 92 93 94 |
|
get_file_link(path)
get a link to the given file
Returns:
Name | Type | Description |
---|---|---|
str |
str
|
The html markup for the RESTFul API to show the file |
Source code in scan/scans.py
41 42 43 44 45 46 47 48 49 50 51 52 53 |
|
get_full_path(path)
Generate the full path for a given relative path.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
path |
str
|
The relative path to be resolved. |
required |
Returns:
Name | Type | Description |
---|---|---|
str |
str
|
The full path combining the scandir and the provided relative path. |
Source code in scan/scans.py
28 29 30 31 32 33 34 35 36 37 38 39 |
|
get_scan_files()
Retrieve the scanned files information from the directory.
Returns:
Type | Description |
---|---|
List[Dict[str, object]]
|
List[Dict[str, object]]: A list of dictionaries, each representing a file. |
List[Dict[str, object]]
|
Each dictionary contains details like file name, last modified time, size, and links for delete and upload actions. |
Source code in scan/scans.py
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 |
|
upload
Created on 2023-11-14
@author: wf
UploadForm
upload form
Source code in scan/upload.py
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 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 |
|
__init__(solution, wiki_users, path)
constructor
Source code in scan/upload.py
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 |
|
run_ocr()
async
run the optical character recognition
Source code in scan/upload.py
168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 |
|
run_upload()
async
actually do the upload
Source code in scan/upload.py
222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 |
|
setup_form()
setup the upload form
Source code in scan/upload.py
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 |
|
to_document(scandir, withOcr=False)
convert my content to a document
Source code in scan/upload.py
210 211 212 213 214 215 216 217 218 219 220 |
|
update()
update the page_link dependend on the page text or selected wiki
Source code in scan/upload.py
196 197 198 199 200 201 202 203 204 205 206 207 208 |
|
update_pdf_viewer_height(e)
async
Update the height of the PDF viewer based on the slider value.
Source code in scan/upload.py
184 185 186 187 188 189 190 191 |
|
UploadLogFilter
Bases: Filter
logging filter for the Uploadform
Source code in scan/upload.py
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 |
|
show_stats(log_view)
Source code in scan/upload.py
52 53 54 55 56 57 58 |
|
version
Created on 2022-02-16
@author: wf
Version
dataclass
Bases: object
Version handling for scan2wiki
Source code in scan/version.py
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 |
|
webcam
Created on 2023-11-16
@author: wf
WebcamForm
allow scanning pictures from a webcam
Source code in scan/webcam.py
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 |
|
__init__(webserver, default_url)
construct me
Source code in scan/webcam.py
24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 |
|
add_product()
async
add the given product
Source code in scan/webcam.py
112 113 114 115 116 117 118 |
|
lookup_gtin()
lookup the global trade identification number e.g. ean
Source code in scan/webcam.py
120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 |
|
run_scan()
async
Start the scan process in the background.
Source code in scan/webcam.py
46 47 48 49 50 51 52 53 |
|
save_webcam_shot()
Fetches an image from the webcam URL and saves it with a timestamp in the specified directory.
Returns:
Name | Type | Description |
---|---|---|
str |
str
|
The file name of the saved webcam image, or an error message if the fetch failed. |
Source code in scan/webcam.py
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 |
|
scan_barcode()
async
Scan for barcodes in the most recently saved webcam image and look up products on Amazon.
Source code in scan/webcam.py
143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 |
|
setup_form()
Setup the webcam form
Source code in scan/webcam.py
88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 |
|
update_preview(image_path=None)
Update the preview with the current URL of the webcam.
Source code in scan/webcam.py
163 164 165 166 167 168 169 170 171 172 173 |
|
update_product_grid()
Update the product grid with the current products.
Source code in scan/webcam.py
105 106 107 108 109 110 |
|