From 9aa6c5bbdd09780312d1f0021fcdda27cc4ff0f1 Mon Sep 17 00:00:00 2001 From: YM162 Date: Fri, 22 Dec 2023 04:44:41 +0100 Subject: [PATCH 01/27] Established the rust + python + wasm project structure. Added a placeholder rust function for testing. --- .gitignore | 8 +- Cargo.lock | 280 ++++++++++++++++++ Cargo.toml | 12 + MANIFEST.in | 2 + .../__pycache__/PDFU_extract.cpython-39.pyc | Bin 2649 -> 0 bytes .../__pycache__/__init__.cpython-37.pyc | Bin 184 -> 0 bytes .../__pycache__/command_line.cpython-37.pyc | Bin 1431 -> 0 bytes .../gulagcleaner_extract.cpython-37.pyc | Bin 2817 -> 0 bytes gulagcleaner/decrypt.py | 7 - gulagcleaner/extract.py | 201 ------------- pyproject.toml | 37 ++- .../gulagcleaner}/__init__.py | 0 python/gulagcleaner/clean.py | 14 + .../gulagcleaner}/command_line.py | 240 +++++++-------- python/gulagcleaner/decrypt.py | 14 + .../gulagcleaner}/metadata.py | 0 rust/gulagcleaner/gulagcleaner.rs | 5 + rust/lib.rs | 10 + rust/python_binder.rs | 9 + rust/wasm_binder.rs | 2 + setup.cfg | 32 -- 21 files changed, 511 insertions(+), 362 deletions(-) create mode 100644 Cargo.lock create mode 100644 Cargo.toml create mode 100644 MANIFEST.in delete mode 100644 gulagcleaner/__pycache__/PDFU_extract.cpython-39.pyc delete mode 100644 gulagcleaner/__pycache__/__init__.cpython-37.pyc delete mode 100644 gulagcleaner/__pycache__/command_line.cpython-37.pyc delete mode 100644 gulagcleaner/__pycache__/gulagcleaner_extract.cpython-37.pyc delete mode 100644 gulagcleaner/decrypt.py delete mode 100644 gulagcleaner/extract.py rename {gulagcleaner => python/gulagcleaner}/__init__.py (100%) create mode 100644 python/gulagcleaner/clean.py rename {gulagcleaner => python/gulagcleaner}/command_line.py (89%) create mode 100644 python/gulagcleaner/decrypt.py rename {gulagcleaner => python/gulagcleaner}/metadata.py (100%) create mode 100644 rust/gulagcleaner/gulagcleaner.rs create mode 100644 rust/lib.rs create mode 100644 rust/python_binder.rs create mode 100644 rust/wasm_binder.rs delete mode 100644 setup.cfg diff --git a/.gitignore b/.gitignore index c0281d8..8393bdb 100644 --- a/.gitignore +++ b/.gitignore @@ -2,4 +2,10 @@ dist multiplepdf tests.ipynb gulagcleaner.egg-info -gulagcleaner/__pycache__ \ No newline at end of file +gulagcleaner/__pycache__ +target +useful_info+scripts.md +.env +.venv +python/gulagcleaner/__pycache__ +*.pyd \ No newline at end of file diff --git a/Cargo.lock b/Cargo.lock new file mode 100644 index 0000000..abb60df --- /dev/null +++ b/Cargo.lock @@ -0,0 +1,280 @@ +# This file is automatically @generated by Cargo. +# It is not intended for manual editing. +version = 3 + +[[package]] +name = "autocfg" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d468802bab17cbc0cc575e9b053f41e72aa36bfa6b7f55e3529ffa43161b97fa" + +[[package]] +name = "bitflags" +version = "1.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a" + +[[package]] +name = "cfg-if" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" + +[[package]] +name = "gulagcleaner" +version = "0.1.0" +dependencies = [ + "pyo3", +] + +[[package]] +name = "heck" +version = "0.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "95505c38b4572b2d910cecb0281560f54b440a19336cbbcb27bf6ce6adc6f5a8" + +[[package]] +name = "indoc" +version = "2.0.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1e186cfbae8084e513daff4240b4797e342f988cecda4fb6c939150f96315fd8" + +[[package]] +name = "libc" +version = "0.2.151" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "302d7ab3130588088d277783b1e2d2e10c9e9e4a16dd9050e6ec93fb3e7048f4" + +[[package]] +name = "lock_api" +version = "0.4.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3c168f8615b12bc01f9c17e2eb0cc07dcae1940121185446edc3744920e8ef45" +dependencies = [ + "autocfg", + "scopeguard", +] + +[[package]] +name = "memoffset" +version = "0.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5a634b1c61a95585bd15607c6ab0c4e5b226e695ff2800ba0cdccddf208c406c" +dependencies = [ + "autocfg", +] + +[[package]] +name = "once_cell" +version = "1.19.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3fdb12b2476b595f9358c5161aa467c2438859caa136dec86c26fdd2efe17b92" + +[[package]] +name = "parking_lot" +version = "0.12.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3742b2c103b9f06bc9fff0a37ff4912935851bee6d36f3c02bcc755bcfec228f" +dependencies = [ + "lock_api", + "parking_lot_core", +] + +[[package]] +name = "parking_lot_core" +version = "0.9.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4c42a9226546d68acdd9c0a280d17ce19bfe27a46bf68784e4066115788d008e" +dependencies = [ + "cfg-if", + "libc", + "redox_syscall", + "smallvec", + "windows-targets", +] + +[[package]] +name = "proc-macro2" +version = "1.0.71" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "75cb1540fadbd5b8fbccc4dddad2734eba435053f725621c070711a14bb5f4b8" +dependencies = [ + "unicode-ident", +] + +[[package]] +name = "pyo3" +version = "0.20.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "04e8453b658fe480c3e70c8ed4e3d3ec33eb74988bd186561b0cc66b85c3bc4b" +dependencies = [ + "cfg-if", + "indoc", + "libc", + "memoffset", + "parking_lot", + "pyo3-build-config", + "pyo3-ffi", + "pyo3-macros", + "unindent", +] + +[[package]] +name = "pyo3-build-config" +version = "0.20.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a96fe70b176a89cff78f2fa7b3c930081e163d5379b4dcdf993e3ae29ca662e5" +dependencies = [ + "once_cell", + "target-lexicon", +] + +[[package]] +name = "pyo3-ffi" +version = "0.20.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "214929900fd25e6604661ed9cf349727c8920d47deff196c4e28165a6ef2a96b" +dependencies = [ + "libc", + "pyo3-build-config", +] + +[[package]] +name = "pyo3-macros" +version = "0.20.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dac53072f717aa1bfa4db832b39de8c875b7c7af4f4a6fe93cdbf9264cf8383b" +dependencies = [ + "proc-macro2", + "pyo3-macros-backend", + "quote", + "syn", +] + +[[package]] +name = "pyo3-macros-backend" +version = "0.20.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7774b5a8282bd4f25f803b1f0d945120be959a36c72e08e7cd031c792fdfd424" +dependencies = [ + "heck", + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "quote" +version = "1.0.33" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5267fca4496028628a95160fc423a33e8b2e6af8a5302579e322e4b520293cae" +dependencies = [ + "proc-macro2", +] + +[[package]] +name = "redox_syscall" +version = "0.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4722d768eff46b75989dd134e5c353f0d6296e5aaa3132e776cbdb56be7731aa" +dependencies = [ + "bitflags", +] + +[[package]] +name = "scopeguard" +version = "1.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "94143f37725109f92c262ed2cf5e59bce7498c01bcc1502d7b9afe439a4e9f49" + +[[package]] +name = "smallvec" +version = "1.11.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4dccd0940a2dcdf68d092b8cbab7dc0ad8fa938bf95787e1b916b0e3d0e8e970" + +[[package]] +name = "syn" +version = "2.0.42" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5b7d0a2c048d661a1a59fcd7355baa232f7ed34e0ee4df2eef3c1c1c0d3852d8" +dependencies = [ + "proc-macro2", + "quote", + "unicode-ident", +] + +[[package]] +name = "target-lexicon" +version = "0.12.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "14c39fd04924ca3a864207c66fc2cd7d22d7c016007f9ce846cbb9326331930a" + +[[package]] +name = "unicode-ident" +version = "1.0.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3354b9ac3fae1ff6755cb6db53683adb661634f67557942dea4facebec0fee4b" + +[[package]] +name = "unindent" +version = "0.2.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c7de7d73e1754487cb58364ee906a499937a0dfabd86bcb980fa99ec8c8fa2ce" + +[[package]] +name = "windows-targets" +version = "0.48.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9a2fa6e2155d7247be68c096456083145c183cbbbc2764150dda45a87197940c" +dependencies = [ + "windows_aarch64_gnullvm", + "windows_aarch64_msvc", + "windows_i686_gnu", + "windows_i686_msvc", + "windows_x86_64_gnu", + "windows_x86_64_gnullvm", + "windows_x86_64_msvc", +] + +[[package]] +name = "windows_aarch64_gnullvm" +version = "0.48.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2b38e32f0abccf9987a4e3079dfb67dcd799fb61361e53e2882c3cbaf0d905d8" + +[[package]] +name = "windows_aarch64_msvc" +version = "0.48.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dc35310971f3b2dbbf3f0690a219f40e2d9afcf64f9ab7cc1be722937c26b4bc" + +[[package]] +name = "windows_i686_gnu" +version = "0.48.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a75915e7def60c94dcef72200b9a8e58e5091744960da64ec734a6c6e9b3743e" + +[[package]] +name = "windows_i686_msvc" +version = "0.48.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8f55c233f70c4b27f66c523580f78f1004e8b5a8b659e05a4eb49d4166cca406" + +[[package]] +name = "windows_x86_64_gnu" +version = "0.48.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "53d40abd2583d23e4718fddf1ebec84dbff8381c07cae67ff7768bbf19c6718e" + +[[package]] +name = "windows_x86_64_gnullvm" +version = "0.48.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0b7b52767868a23d5bab768e390dc5f5c55825b6d30b86c844ff2dc7414044cc" + +[[package]] +name = "windows_x86_64_msvc" +version = "0.48.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ed94fce61571a4006852b7389a063ab983c02eb1bb37b47f8272ce92d06d9538" diff --git a/Cargo.toml b/Cargo.toml new file mode 100644 index 0000000..123e0ad --- /dev/null +++ b/Cargo.toml @@ -0,0 +1,12 @@ +[package] +name = "gulagcleaner" +version = "0.1.0" +edition = "2021" + +# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html +[lib] +name = "gulagcleaner_lib" +crate-type = ["cdylib"] +path = "rust/lib.rs" +[dependencies] +pyo3 = { version = "0.20.0", features = ["extension-module"] } \ No newline at end of file diff --git a/MANIFEST.in b/MANIFEST.in new file mode 100644 index 0000000..b38e2c2 --- /dev/null +++ b/MANIFEST.in @@ -0,0 +1,2 @@ +include Cargo.toml +recursive-include rust *.rs \ No newline at end of file diff --git a/gulagcleaner/__pycache__/PDFU_extract.cpython-39.pyc b/gulagcleaner/__pycache__/PDFU_extract.cpython-39.pyc deleted file mode 100644 index 735bd16b3c7270e320fe05f64be63b439e2d9cd6..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 2649 zcmZuzOK%*<5$>M%&OS)V6m2;+G8S_18p%>Vh9Ml&q8TJW2*HvqWB_B)obFwYG>=Vp zkEmVD1_78HZ3xKKK$gekk{ol-Ek9w9TQ1>WFbv35Jxh@UJcF&N?yml-x~jTrS-&3= zc>em2za0OoOUVClaQ(4i@G<<}7v zP8Q^yxMO%Xqj?yIhNoFK?sAX&e@2fPE{z8LWEnI&tn!MkUa60srrymv;C=kyU7 z_AkH+ax}D>&O<)=OfW8_VV}rU3kmbxQ^{uI^7yGpbkm!p1z!);kTyPSI%2s1)&@4A zh_-&v4L6>0PpB8T8fAqmGhaWBcjOn!a*@qXndSM~Km|ZwXTp&X)_V;CSl0GkEcfZo5 zjKh7EP79_h$rk+wl~iRkkA5W?FXP~lB~_*wkGr22>2o1f${8PqjXPsgp&EadJ`*!O ziMM7kNx{hgCC7d!JZPgP#-Jd`CSjoNv5aQOKZ8N*)55goAjK_ib2}y6`Nmn& zmvr$(O}NXwKUz*VB;ccifHliFH2fbMbEp!eT|{S;^2bCmUNt^uN>eI3-!(~b_GcH!5XSbXpm z>T)6bz1oGW--cZGR((CFeZIjr&uo+F|Ir(@dq(-KXVyz9-_e_^TQ|{B>h;NPUq9J3 zxi{V<%Rt|*1JDRJV)X{zEwH$=+AXS&Y1PCHE;>CCQoOchl4c@GRg{$p*uz^O+-V>_6L9^DYk1O3jB_>JjSk?Nj9MG@i4-Dw z&az5e6GoUvRgws$cBA96%;1c0x3CmV(G2j1Yz>hm3Pq<(MXKE}sj@3u5NNHrJURygD&sa_jE^j@Le#3L#1pHLWQtn0oRTWoCufSNug-T>P!-{f=C~#AYv$*|O z&haF=ybST~VMB&ay*gSrBZ!auF~2o<&dEU5jv>Ld}(kGo?-^rXUNef{zv(<10TR-eVcTzTq}hd#IyYVnb}45~{K( zWU-^zbJ4g-Rw^N}*E9~6UWt814v=_2V&|}wdF&okc|MnSa2mT&V`rjhtWq_e6nP1~ z1xzJzz&LMvi+hS)yy<-UA`vDu!)_daRVK~j@G3#&He$YwyKPvH-51dCl@4HH_V4p) zS}rTk;ObH~!iK7zXtlAY>5I0d?pm4dC^x(6Zp$gR(xb zwrOB((YIkWpj#jXV%HZ#3G0x&a*sDJ<^n7iE#=^cIOpLI*qC1Sw zO=RMJyVCwEQYJg`kg3Q#cWDxxrM8E(ekl_Ht#VkM~g&~+hlhJP_LlH+(JMo0 zVGG_9 zduizvOYg0JX(8{uGgtPd&2Enf9HZTbW9hOFknD`e8xuWU_F+52Wp|L?9TE1?h}

zHd?cL9d>`s9(35pYxYTpeY$2rhkdqYyB+p9vM;Vz^ZNMp@k=}#toPnCz><-0_(Yfc z;JVz+_)(VTX+c>D0pkHJ>LN}{q4kQLw(pm9nbE~`Y%05gGEoD@MGR>r)3Q(&dc8Nk z#6hQ^kO<{5eoE_1Hs%DH-edy2%4p10A2`oZZ78U|kR|X)Ld~1ezdYcX&KZ=DCb*(( zY$+R4N#){w(7Egd&nk?&Z2FVQlEX;}f-A4p1h4Po?r2qlq(NGomXOmp{r$HBx6;N9 zz2|itb0M0&LtM%UXDls}KwQJqI-3TM(~Jj#E;+*p;Q+X-p@=Ff7ftUcE-9mu?l-*| z#EW!U?gyc*Y3Qv%jon&C{ONkK6RMcDt(YPJq)5M^)?JOM2Ie$Z_E4>bM9 zG{z!QhV%Rzz1etCq_|s=vUXt5F&p<00OnRs`yLOJB`$>W@k}bJ%d|Ozq|SLEkF*JD zNEwT8v}LN_I%!(~e)2>)6{Lj({keyDq;0)G{}x~i#n^#c+RJUHfwJ{PWuXl5oZG79 zBKeiTJ@k6d5BBFTFsGQ$vL%IbKC7xjEam)Z8PjZjgqI3vF6KuUa#0rR*EiqJpQa~s zkxD+PX#9#MT+F+Fim&4`&uPJ;EG_u7x=?mb(?b6r#1sWFe8a`QZ46QBel0f*{rJXC z=h-&l0nSi<6zLdI)a)J5EDKJd%mcaL!EQJ4Zm`Zg9sA+1JJOa*d8L@@I|CNRgxgx& mL@#L0qX_P3rc2Wi`t~aSVP3L2 diff --git a/gulagcleaner/__pycache__/gulagcleaner_extract.cpython-37.pyc b/gulagcleaner/__pycache__/gulagcleaner_extract.cpython-37.pyc deleted file mode 100644 index ca8e61f78d7bdae10a20031331ec7854cca1041c..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 2817 zcmaJDO>g7Ib%vx!ijuruujAcK+k{x4NQ8FXLkbiy7Qs5}xDAjRMs|Zu2^GSaGm^OG zS7%1HB~V2Hx5ohe0XfLW{*Crh^e6DzOMUC9hoHdry`lVd*bc$R;mrG*_c@>SdI5p) z>G$LKKOI8;i9c7vg2{7u)gJ(G!f8sP=1U_A|5j>cc4TKx2N~qQJ~)+KD=V@21_X7xiGxw8q;!fbTuA&O67Jti*lZJ*TiwUy^?B z60{%(eXDLC^3hjPPiy?E%pN%LGhqn8K$k z&a`B)9%`7x6uHB2;Pv2r0k8TJfF>0vz^!ks1=UnroK$paUyyU_oGz@&;`U<#kQ(S1 z*fP*H(0fd{|DC(AD;o~cKDb0deH!^0J1f~(D2WS~XzNQG0V;6W0?>DBZ&${X0kC zJ4#Y8RUN1@O>~;%LiL^6FZpO#GCipsv;=4-G&A^S#*;$ch184Go5MhX^XpmvcNmuu`Qo-^rZic@HTvdXW-G7MAM~Jkqf%8XPepvPITc^ z4(xZHk=G>Oqy!(3VuJKHB)7gHmA!O;x650Gckdz4Q(SFbAg+6N4>-28r~Rt+rmcfF z9eBGVi?4l)vE`1*!aMt*a`(t@w-$coEqi*c^7%c!er_Yz-~Hn?(f2C%obvm}a4Pvj zy}rDER|4W)pKasjY!wCkpWnju9+E{n2i+HKy-~G6eozI=2bE{^50;xo|Mlg2Rl900 zxA+5YUsxAl+jq#^Z0rfx7Jsj?r$h9^;{fFTm6An=lKJM9W>x1#Gwv=rzwdlQ8hdgV zvSy3@8=M@3F!qGVjs#bso`?_vH)J^vV=0&xDr8|UPQ$~!{V>T5f`Wt(M@0&yB0Np> zBor(LfE>8sA?Baq3g`_ju56nn19s(D?U)(LzRHuG@D&P&j0sOCLW*l$AiYGGs4#_W z(1JINkkYXDN=kQ))Z0NDb;R*&NPA$0m1kv=@QZv@$PA7R zRP3mjYNHb>a@Sf&zABp6C%kqbZsIV-^#5#M7uk2?+$p~AM!PD?@5Z=QtZ$Hv#`BF= za)xf!#Z}nv?AHV;wzrCjx^v5;b;~%RcF=m4|9$)R?ZMpHhM1Kes?(9R*M6JDPmd$FHmB4^YY_PSR zioCW8Rl8DT1++`hl|(+{+>qC;Q@mB+ZVol1_M|9N7K^(5`B^MX@b+- z%aL0GGMN35kpr`+bq1FbrLhy2f4dkbIa9R*?6ca1NG_+)nTqwQ9tL!cI&_`-@HkdrS@7*bTU@iYsBdl3_hC1nTYv@shy!~YmIJc@_YupiZkVt9 z1jYEnVaAetIGq3Z1xwR#B#X?X*pu6x`biiUSq3F{yT2hn0=md6lVdzBm>rIM+Bn15 za?LDk<24LVZ_M6!sMqW?7d0i(Q;ml$DWV6knZeCOZcmc&WSEK*k(xV<@%**2=#}A6 oK0#W%n%n}$Z2q&X;L}uminl9;j>0pq!_$Qa>}C0D{;z!cKN;fkJ^%m! diff --git a/gulagcleaner/decrypt.py b/gulagcleaner/decrypt.py deleted file mode 100644 index f0ff827..0000000 --- a/gulagcleaner/decrypt.py +++ /dev/null @@ -1,7 +0,0 @@ -import pikepdf - -def decrypt_pdf(pdf_path): - intermediate_pdf_path = pdf_path[:-4] + "_inter.pdf" - with pikepdf.Pdf.open(pdf_path) as pdf: - pdf.save(intermediate_pdf_path) - return intermediate_pdf_path diff --git a/gulagcleaner/extract.py b/gulagcleaner/extract.py deleted file mode 100644 index 5ae16cf..0000000 --- a/gulagcleaner/extract.py +++ /dev/null @@ -1,201 +0,0 @@ -from pdfrw import PdfReader, PdfWriter -from pdfrw.findobjs import wrap_object, find_objects -from pdfrw.objects import PdfName, PdfArray - -def find_iobj_pairs(first_page, second_page): - """ - Finds the indirect objects that repeat between pages. - - Args: - first_page (PDFPage): The first page. - second_page (PDFPage): The second page. - - Returns: - return (tuple): (first_page,first_pair_index) - first_pair_index (int): index of the first repeating indirect object on the first page. - - """ - comunes = tuple(set(first_page).intersection(second_page)) - if first_page.index(comunes[0]) < first_page.index(comunes[1]): - return (first_page,first_page.index(comunes[0]),first_page.index(comunes[1])) - else: - return (first_page,first_page.index(comunes[1]),first_page.index(comunes[0])) - -def clean_pdf(pdf_path, output_path="", method="auto"): - """ - De-embeds the PDF file and creates a new PDF file in the same folder with each embedded page in a new page. - - Args: - pdf_path (str): The path to the PDF file. - output_path (str): The path to the output PDF file. - method (str, optional): Defines what strategy will be used to clean the pdf file. Can be "new", "old", "naive" or "auto". - Default is "new". - - Returns: - return_msg (dict): A dictionary with the following keys: - success (bool): Indicates whether the de-embedding process was successful. - return_path (str): The path to the de-embedded file if successful. - error (str): An error description if the process was unsuccessful. - """ - - if not pdf_path.endswith(".pdf"): - return { - "Success": False, - "return_path": "", - "Error": "File is not a .pdf file.", - } - - if output_path == "": - output_path = pdf_path[:-4] + "_clean.pdf" - - try: - pdf = PdfReader(pdf_path) - - # Old method, for files older than 18/05/2023. Works by finding the embedded pages and creating new pages with them. - if method=="old": - xobjs = [] - for page in pdf.pages: - xobjs.extend([page.Resources.XObject[object] for object in page.Resources.XObject if "EmbeddedPdfPage" in str(object)]) - newpages = [wrap_object(item, 1000, 0.5 * 72) for item in xobjs] - - if not xobjs: - return { - "Success": False, - "return_path": "", - "Error": "No embedded pages found." - } - - # New method, for files newer than 18/05/2023. Works by finding the repeating indirect objects between pages and creating new pages with them. - elif method=="new": - content_list = [] - for page in pdf.pages: - content = [content.indirect for content in page.Contents] - if len(content)>1: - content_list.append(content) - - new_contents = [] - for i in range(0,len(content_list)): - if i == len(content_list)-1: - pares = find_iobj_pairs(content_list[i], content_list[i-1]) - else: - pares = find_iobj_pairs(content_list[i], content_list[i + 1]) - new_contents.append(pares[0][pares[1]-2:pares[2]+4]) - - newpages = [] - for i,page in enumerate([page for page in pdf.pages if len(page.Contents)>1]): - newpage = page.copy() - newpage.Contents = [pdf.indirect_objects[iobj] for iobj in new_contents[i]] - newpage.Annots = [] - newpage.MediaBox = PdfArray([0,0,float(newpage.MediaBox[2])-float(newpage.MediaBox[0]),float(newpage.MediaBox[3])-float(newpage.MediaBox[1])]) - newpage.BleedBox = PdfArray([0,0,float(newpage.BleedBox[2])-float(newpage.BleedBox[0]),float(newpage.BleedBox[3])-float(newpage.BleedBox[1])]) - newpage.TrimBox = PdfArray([0,0,float(newpage.TrimBox[2])-float(newpage.TrimBox[0]),float(newpage.TrimBox[3])-float(newpage.TrimBox[1])]) - newpage.ArtBox = PdfArray([0,0,float(newpage.ArtBox[2])-float(newpage.ArtBox[0]),float(newpage.ArtBox[3])-float(newpage.ArtBox[1])]) - newpage.CropBox = PdfArray([0,0,float(newpage.CropBox[2])-float(newpage.CropBox[0]),float(newpage.CropBox[3])-float(newpage.CropBox[1])]) - newpages.append(newpage) - - #Naive method. Just detects the pages with ads and crops them. THIS METHOD IS NOT RECOMENDED AT ALL. It is very unreliable and when copying text from the outputed pdf the ads and watermaks are copied as well, because we are just "hiding" them from the user, not truly removing them. - elif method=="naive": - #Not yet implemented. - newpages = [] - for page in pdf.pages: - page_type = get_page_type(page) - if page_type == "banner_ads": - newpage = page.copy() - #TODO: Set MediaBox,BleedBox...etc - - - newpages.append(newpage) - - if page_type == "watermark": - newpage = page.copy() - #TODO: Set MediaBox,BleedBox...etc - - - - newpages.append(newpage) - - if page_type == "full_page_ads": - continue - - if page_type == "unknown": - newpages.append(page) - - logo_dims = [(71,390),(37,203),(73,390)] - for logo in [image for image in find_objects(page,valid_subtypes=(PdfName.Image, PdfName.Dummy)) if (int(image.Height),int(image.Width)) in logo_dims]: - logo.Height = 0 - logo.Width = 0 - #TODO: We scale annotations to 0,0 - - elif method == "auto": - return auto_clean_pdf(pdf, pdf_path, output_path) - - else: - return { - "Success": False, - "return_path": "", - "Error": "Cleaning method not found." - } - - writer = PdfWriter(output_path) - writer.addpages(newpages) - writer.write() - - return { - "Success": True, - "return_path": output_path, - "Error": "" - } - - except Exception as e: - return { - "Success": False, - "return_path": "", - "Error": str(e), - "Meta": {} - } - - -def auto_clean_pdf(pdf, pdf_path, output_path): - #Test for the new method - content_list = [] - for page in pdf.pages: - content = [content.indirect for content in page.Contents] - if len(content)>1: - content_list.append(content) - - if len(content_list)>0 and len(tuple(set(content_list[0]).intersection(content_list[1])))>1: - return clean_pdf(pdf_path, output_path, method="new") - - #Test for the old method - xobjs = [] - for page in pdf.pages: - xobjs.extend([page.Resources.XObject[object] for object in page.Resources.XObject if "EmbeddedPdfPage" in str(object)]) - - if len(xobjs)>0: - return clean_pdf(pdf_path, output_path, method="old") - - #We don't know what method to use, so we use the naive one. - return clean_pdf(pdf_path, output_path, method="naive") - -def get_page_type(page): - images = [(image.Height,image.Width) for image in find_objects(page,valid_subtypes=(PdfName.Image, PdfName.Dummy))] - - #There has to be a better way to do this, but this works for 99.9% of the cases. - logo_dims = [(71,390),(37,203),(73,390)] - horizontal_banner_dims = [(247,1414),(213,1219),(215,1219),(249,1414),(217,1240)] - vertical_banner_dims = [(1753,170),(1518,248),(1520,147),(1753,177),(1751,171),(1537,147)] - full_page_dims = [(842,595),(1754,1240),(2526,1785),(1733,1219),(3508,2480),(2339,1653)] - - has_logo = len(tuple(set(logo_dims).intersection(images)))>0 - has_horizontal_banner = len(tuple(set(logo_dims).intersection(images)))>0 - has_vertical_banner = len(tuple(set(logo_dims).intersection(images)))>0 - has_full_page = len(tuple(set(logo_dims).intersection(images)))>0 - - if has_horizontal_banner and has_vertical_banner: - return "banner_ads" - elif has_full_page: - return "full_page_ads" - elif has_logo: - return "watermark" - else: - return "unknown" \ No newline at end of file diff --git a/pyproject.toml b/pyproject.toml index fa7093a..b0ff0eb 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,3 +1,36 @@ [build-system] -requires = ["setuptools>=42"] -build-backend = "setuptools.build_meta" \ No newline at end of file +requires = ["setuptools", "setuptools-rust"] +build-backend = "setuptools.build_meta" + +[project] +name = "gulagcleaner" +version = "0.0.1" +description = "Ad removal tool for PDFs written in python." +authors = [ + {name = "YM162", email = "david.fontaneda16@gmail.com"}] +readme = "README.md" +dependencies = [ + "pikepdf>=5.1.2","pdfminer.six>=20220524","pdfrw>=0.4" +] +license = {file = "LICENSE"} +classifiers = ["Programming Language :: Python :: 3", + "License :: OSI Approved :: MIT License", + "Operating System :: OS Independent"] +keywords = ["wuolah", "pdf", "ads", "advertisments", "cleaner", "gulagcleaner"] + +[project.urls] +homepage = "https://github.com/YM162/gulag-cleaner-cli" +repository = "https://github.com/YM162/gulag-cleaner-cli.git" +issues = "https://github.com/YM162/gulag-cleaner-cli/issues" + +[project.scripts] +gulagcleaner = "gulagcleaner.command_line:main" + + +[tool.setuptools.packages] +# Pure Python packages/modules +find = { where = ["python"] } + +[[tool.setuptools-rust.ext-modules]] +# Private Rust extension module to be nested into Python package +target = "gulagcleaner._lib" # The last part of the name (e.g. "_lib") has to match lib.name in Cargo.toml, \ No newline at end of file diff --git a/gulagcleaner/__init__.py b/python/gulagcleaner/__init__.py similarity index 100% rename from gulagcleaner/__init__.py rename to python/gulagcleaner/__init__.py diff --git a/python/gulagcleaner/clean.py b/python/gulagcleaner/clean.py new file mode 100644 index 0000000..46f5ea8 --- /dev/null +++ b/python/gulagcleaner/clean.py @@ -0,0 +1,14 @@ +from ._lib import sum_as_string # export public parts of the binary extension + +#Here there should only be a function clean_pdf(pdf_path, output_path, force_naive) +#that calls the rust function and then saves the pdf in the given output_path. +#It should return a dictionary with the following keys: +# Returns: +# return_msg (dict): A dictionary with the following keys: +# success (bool): Indicates whether the de-embedding process was successful. +# return_path (str): The path to the de-embedded file if successful. +# error (str): An error description if the process was unsuccessful. +# """ + +def clean_pdf(pdf_path, output_path, force_naive): + return sum_as_string(10,6) \ No newline at end of file diff --git a/gulagcleaner/command_line.py b/python/gulagcleaner/command_line.py similarity index 89% rename from gulagcleaner/command_line.py rename to python/gulagcleaner/command_line.py index f037ef4..88a8aac 100644 --- a/gulagcleaner/command_line.py +++ b/python/gulagcleaner/command_line.py @@ -1,119 +1,121 @@ -from gulagcleaner.extract import clean_pdf -from gulagcleaner.decrypt import decrypt_pdf -from gulagcleaner.metadata import extract_metadata -from os.path import exists, isdir, join -from os import listdir, remove - -def parseArgs(): - ''' - Function to parse arguments. - - Checks for any optional arguments passed to the program and activates - the corresponding flags. - ''' - from sys import argv - targeted = ['-h', '-r', '-s', '-v', argv[0]] - - return { - 'help': '-h' in argv, - 'replace': '-r' in argv, - 'short': '-s' in argv, - 'version': '-v' in argv, - 'files': [arg for arg in argv if arg not in targeted] - } - -def main(): - ''' - Main function for the "gulagcleaner" CLI command. - - The "gulagcleaner" command takes arguments for the path of one or more - files which can be PDF files or folders containing PDFs, and tries to - remove the ads inside of them. The new PDFs are saved in their original - location. - - Available CLI arguments: - -h : Display help information. - -r : Replace original files with their cleaned version. - -s : Do not show metadata about cleaned files. - -v : Display the version of the program. - - ''' - arguments = parseArgs() - - # Check for the -h argument - if arguments["help"]: - print("Usage: gulagcleaner [-h] [-r] [-s] [-v] ...") - print("") - print("Removes ads from PDF files.") - print("") - print("Positional arguments:") - print(" pdf_path PDF file to clean.") - print("") - print("Optional arguments:") - print(" -h Show this help message.") - print(" -r Replace original files with their cleaned version.") - print(" -s Do not show metadata about cleaned files.") - print(" -v Show the version of the program.") - return - - # Check for the -v argument - if arguments["version"]: - print("Current version: 0.8.2") - return - - # Get the pdf_path argument - if len(arguments["files"]) == 0: - print('Usage: gulagcleaner [-h] [-r] [-s] [-v] ...') - return - - replace = arguments["replace"] - short = arguments["short"] - - for element in arguments["files"]: - # Check if the file exists - if not exists(element): - print(element + " not found.") - continue - - # Check if file is a directory - if isdir(element): - # Add PDF files of directory to list of files to clean - arguments["files"] += [join(element, file) for file in listdir(element) - if file.endswith('.pdf') or isdir(join(element, file))] - continue - - pdf_path = element - - if replace: - output_path = pdf_path - else: - output_path = pdf_path[:-4] + "_clean.pdf" - - # We decrypt the PDF file - pdf_path = decrypt_pdf(pdf_path) - - # If short mode is not active, extract metadata - if not short: - try: - metadict = extract_metadata(pdf_path) - print("Metadata:") - print("Archivo: " + metadict["Archivo"]) - print("Autor: " + metadict["Autor"]) - print("Asignatura: " + metadict["Asignatura"]) - print("Curso y Grado: " + metadict["Curso y Grado"]) - print("Facultad: " + metadict["Facultad"]) - print("Universidad: " + metadict["Universidad"]) - except Exception as e: - print("Failed to extract metadata:", e) - - # Call the cleaning function - return_msg = clean_pdf(pdf_path, output_path) - remove(pdf_path) - if return_msg["Success"]: - print("Cleaning successful. File saved in " + - return_msg["return_path"]) - else: - print("Error cleaning " + pdf_path + ": " + return_msg["Error"]) - -if __name__ == "__main__": - print('Call from the "gulagcleaner" command.') +from gulagcleaner.clean import clean_pdf +from gulagcleaner.decrypt import decrypt_pdf +from gulagcleaner.metadata import extract_metadata +from os.path import exists, isdir, join +from os import listdir, remove + +def parseArgs(): + ''' + Function to parse arguments. + + Checks for any optional arguments passed to the program and activates + the corresponding flags. + ''' + from sys import argv + targeted = ['-h', '-r', '-s', '-v','-n', argv[0]] + + return { + 'help': '-h' in argv, + 'replace': '-r' in argv, + 'short': '-s' in argv, + 'version': '-v' in argv, + 'force_naive': '-n' in argv, + 'files': [arg for arg in argv if arg not in targeted] + } + +def main(): + ''' + Main function for the "gulagcleaner" CLI command. + + The "gulagcleaner" command takes arguments for the path of one or more + files which can be PDF files or folders containing PDFs, and tries to + remove the ads inside of them. The new PDFs are saved in their original + location. + + Available CLI arguments: + -h : Display help information. + -r : Replace original files with their cleaned version. + -s : Do not show metadata about cleaned files. + -v : Display the version of the program. + + ''' + arguments = parseArgs() + + # Check for the -h argument + if arguments["help"]: + print("Usage: gulagcleaner [-h] [-r] [-s] [-v] [-n] ") + print("") + print("Removes ads from PDF files.") + print("") + print("Positional arguments:") + print(" pdf_path PDF file to clean.") + print("") + print("Optional arguments:") + print(" -h Show this help message.") + print(" -r Replace original files with their cleaned version.") + print(" -s Do not show metadata about cleaned files.") + print(" -v Show the version of the program.") + print(" -n Force the naive cleaning method.") + return + + # Check for the -v argument + if arguments["version"]: + print("Current version: 0.8.2") + return + + # Get the pdf_path argument + if len(arguments["files"]) == 0: + print('Usage: gulagcleaner [-h] [-r] [-s] [-v] [-n] ...') + return + + replace = arguments["replace"] + short = arguments["short"] + force_naive = arguments["force_naive"] + for element in arguments["files"]: + # Check if the file exists + if not exists(element): + print(element + " not found.") + continue + + # Check if file is a directory + if isdir(element): + # Add PDF files of directory to list of files to clean + arguments["files"] += [join(element, file) for file in listdir(element) + if file.endswith('.pdf') or isdir(join(element, file))] + continue + + pdf_path = element + + if replace: + output_path = pdf_path + else: + output_path = pdf_path[:-4] + "_clean.pdf" + + # We decrypt the PDF file + pdf_path = decrypt_pdf(pdf_path) + + # If short mode is not active, extract metadata + if not short: + try: + metadict = extract_metadata(pdf_path) + print("Metadata:") + print("Archivo: " + metadict["Archivo"]) + print("Autor: " + metadict["Autor"]) + print("Asignatura: " + metadict["Asignatura"]) + print("Curso y Grado: " + metadict["Curso y Grado"]) + print("Facultad: " + metadict["Facultad"]) + print("Universidad: " + metadict["Universidad"]) + except Exception as e: + print("Failed to extract metadata:", e) + + # Call the cleaning function + return_msg = clean_pdf(pdf_path, output_path, force_naive) + remove(pdf_path) + if return_msg["Success"]: + print("Cleaning successful. File saved in " + + return_msg["return_path"]) + else: + print("Error cleaning " + pdf_path + ": " + return_msg["Error"]) + +if __name__ == "__main__": + print('Call from the "gulagcleaner" command.') diff --git a/python/gulagcleaner/decrypt.py b/python/gulagcleaner/decrypt.py new file mode 100644 index 0000000..2b7d0b4 --- /dev/null +++ b/python/gulagcleaner/decrypt.py @@ -0,0 +1,14 @@ +import pikepdf + +def decrypt_pdf(pdf_path): + """ + Decrypts a PDF file and returns the path to the decrypted file. + Args: + pdf_path (str): The path to the pdf file. + Returns: + intermediate_pdf_path (str): The path to the decrypted pdf file. + """ + intermediate_pdf_path = pdf_path[:-4] + "_inter.pdf" + with pikepdf.Pdf.open(pdf_path) as pdf: + pdf.save(intermediate_pdf_path) + return intermediate_pdf_path diff --git a/gulagcleaner/metadata.py b/python/gulagcleaner/metadata.py similarity index 100% rename from gulagcleaner/metadata.py rename to python/gulagcleaner/metadata.py diff --git a/rust/gulagcleaner/gulagcleaner.rs b/rust/gulagcleaner/gulagcleaner.rs new file mode 100644 index 0000000..f07cde7 --- /dev/null +++ b/rust/gulagcleaner/gulagcleaner.rs @@ -0,0 +1,5 @@ +//Here I should place my gulagcleaner-rust functions, and then call clean_pdf from python_binder.rs + +pub fn sum_as_string(a: usize, b: usize) -> String { + (a + b).to_string() +} \ No newline at end of file diff --git a/rust/lib.rs b/rust/lib.rs new file mode 100644 index 0000000..b2c7a25 --- /dev/null +++ b/rust/lib.rs @@ -0,0 +1,10 @@ +use pyo3::prelude::*; + +mod python_binder; + +/// I only need to replace the sum_as_string function with the clean_pdf function +#[pymodule] +fn _lib(_py: Python, m: &PyModule) -> PyResult<()> { + m.add_function(wrap_pyfunction!(python_binder::sum_as_string, m)?)?; + Ok(()) +} diff --git a/rust/python_binder.rs b/rust/python_binder.rs new file mode 100644 index 0000000..1235a25 --- /dev/null +++ b/rust/python_binder.rs @@ -0,0 +1,9 @@ +use pyo3::prelude::*; + +#[path = "gulagcleaner/gulagcleaner.rs"] mod gulagcleaner; + +/// I only need to replace the sum_as_string function with the clean_pdf function, and the arguments to be u8 vectors. Maybe I need to change some types here to pure rust. +#[pyfunction] +pub fn sum_as_string(a: usize, b: usize) -> PyResult { + Ok(gulagcleaner::sum_as_string(a, b)) +} \ No newline at end of file diff --git a/rust/wasm_binder.rs b/rust/wasm_binder.rs new file mode 100644 index 0000000..7a4c807 --- /dev/null +++ b/rust/wasm_binder.rs @@ -0,0 +1,2 @@ +//It would be nice to abstract the #[wasm_bindgen] or however its called into here, so i can still use the same code for the wasm and the python version. +#[path = "gulagcleaner/gulagcleaner.rs"] mod gulagcleaner; \ No newline at end of file diff --git a/setup.cfg b/setup.cfg deleted file mode 100644 index c96b125..0000000 --- a/setup.cfg +++ /dev/null @@ -1,32 +0,0 @@ -[metadata] -name = gulagcleaner -version = 0.8.2 -author = YM162 -author_email = david.fontaneda16@gmail.com -description = Ad removal tool for PDFs written in python. -long_description = file: README.md -long_description_content_type = text/markdown -url = https://github.com/YM162/gulag-cleaner-cli -project_urls = - Bug Tracker = https://github.com/YM162/gulag-cleaner-cli/issues -classifiers = - Programming Language :: Python :: 3 - License :: OSI Approved :: MIT License - Operating System :: OS Independent - -[options] -install_requires = - pdfrw>=0.4 - pikepdf>=5.1.2 - pdfminer.six>=20220524 - -packages = find: -python_requires = >=3.6 - -[options.packages.find] -exclude = - tests - -[options.entry_points] -console_scripts = - gulagcleaner = gulagcleaner.command_line:main From bd500bfbc78f496ae96c88c2c3ac44e05097b577 Mon Sep 17 00:00:00 2001 From: YM162 Date: Fri, 22 Dec 2023 20:39:06 +0100 Subject: [PATCH 02/27] Improved the project structure and added WASM compiling support. --- .gitignore | 2 +- Cargo.lock | 405 ++++++++++++++++++ Cargo.toml | 17 +- gulagcleaner/Cargo.toml | 15 + .../src/lib.rs | 0 gulagcleaner_python/Cargo.toml | 14 + .../MANIFEST.in | 0 .../pyproject.toml | 2 +- .../python}/gulagcleaner/__init__.py | 0 .../__pycache__/__init__.cpython-38.pyc | Bin 0 -> 170 bytes .../__pycache__/clean.cpython-38.pyc | Bin 0 -> 362 bytes .../__pycache__/command_line.cpython-38.pyc | Bin 0 -> 3616 bytes .../__pycache__/decrypt.cpython-38.pyc | Bin 0 -> 642 bytes .../__pycache__/metadata.cpython-38.pyc | Bin 0 -> 1119 bytes .../python}/gulagcleaner/clean.py | 0 .../python}/gulagcleaner/command_line.py | 0 .../python}/gulagcleaner/decrypt.py | 0 .../python}/gulagcleaner/metadata.py | 0 .../rust/lib.rs | 13 +- gulagcleaner_wasm/Cargo.toml | 13 + gulagcleaner_wasm/src/lib.rs | 7 + rust/lib.rs | 10 - rust/wasm_binder.rs | 2 - 23 files changed, 472 insertions(+), 28 deletions(-) create mode 100644 gulagcleaner/Cargo.toml rename rust/gulagcleaner/gulagcleaner.rs => gulagcleaner/src/lib.rs (100%) create mode 100644 gulagcleaner_python/Cargo.toml rename MANIFEST.in => gulagcleaner_python/MANIFEST.in (100%) rename pyproject.toml => gulagcleaner_python/pyproject.toml (95%) rename {python => gulagcleaner_python/python}/gulagcleaner/__init__.py (100%) create mode 100644 gulagcleaner_python/python/gulagcleaner/__pycache__/__init__.cpython-38.pyc create mode 100644 gulagcleaner_python/python/gulagcleaner/__pycache__/clean.cpython-38.pyc create mode 100644 gulagcleaner_python/python/gulagcleaner/__pycache__/command_line.cpython-38.pyc create mode 100644 gulagcleaner_python/python/gulagcleaner/__pycache__/decrypt.cpython-38.pyc create mode 100644 gulagcleaner_python/python/gulagcleaner/__pycache__/metadata.cpython-38.pyc rename {python => gulagcleaner_python/python}/gulagcleaner/clean.py (100%) rename {python => gulagcleaner_python/python}/gulagcleaner/command_line.py (100%) rename {python => gulagcleaner_python/python}/gulagcleaner/decrypt.py (100%) rename {python => gulagcleaner_python/python}/gulagcleaner/metadata.py (100%) rename rust/python_binder.rs => gulagcleaner_python/rust/lib.rs (56%) create mode 100644 gulagcleaner_wasm/Cargo.toml create mode 100644 gulagcleaner_wasm/src/lib.rs delete mode 100644 rust/lib.rs delete mode 100644 rust/wasm_binder.rs diff --git a/.gitignore b/.gitignore index 8393bdb..fb32e01 100644 --- a/.gitignore +++ b/.gitignore @@ -4,7 +4,7 @@ tests.ipynb gulagcleaner.egg-info gulagcleaner/__pycache__ target -useful_info+scripts.md +useful_info+scripts+TODO.md .env .venv python/gulagcleaner/__pycache__ diff --git a/Cargo.lock b/Cargo.lock index abb60df..6d990ce 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2,6 +2,27 @@ # It is not intended for manual editing. version = 3 +[[package]] +name = "adler" +version = "1.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f26201604c87b1e01bd3d98f8d5d9a8fcbb815e8cedb41ffccbeb4bf593a35fe" + +[[package]] +name = "android-tzdata" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e999941b234f3131b00bc13c22d06e8c5ff726d1b6318ac7eb276997bbb4fef0" + +[[package]] +name = "android_system_properties" +version = "0.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "819e7219dbd41043ac279b19830f2efc897156490d7fd6ea916720117ee66311" +dependencies = [ + "libc", +] + [[package]] name = "autocfg" version = "1.1.0" @@ -14,37 +35,206 @@ version = "1.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a" +[[package]] +name = "bumpalo" +version = "3.14.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7f30e7476521f6f8af1a1c4c0b8cc94f0bee37d91763d0ca2665f299b6cd8aec" + +[[package]] +name = "cc" +version = "1.0.83" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f1174fb0b6ec23863f8b971027804a42614e347eafb0a95bf0b12cdae21fc4d0" +dependencies = [ + "libc", +] + [[package]] name = "cfg-if" version = "1.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" +[[package]] +name = "chrono" +version = "0.4.31" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7f2c685bad3eb3d45a01354cedb7d5faa66194d1d58ba6e267a8de788f79db38" +dependencies = [ + "android-tzdata", + "iana-time-zone", + "num-traits", + "windows-targets", +] + +[[package]] +name = "core-foundation-sys" +version = "0.8.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "06ea2b9bc92be3c2baa9334a323ebca2d6f074ff852cd1d7b11064035cd3868f" + +[[package]] +name = "crc32fast" +version = "1.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b540bd8bc810d3885c6ea91e2018302f68baba2129ab3e88f32389ee9370880d" +dependencies = [ + "cfg-if", +] + +[[package]] +name = "crossbeam-deque" +version = "0.8.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fca89a0e215bab21874660c67903c5f143333cab1da83d041c7ded6053774751" +dependencies = [ + "cfg-if", + "crossbeam-epoch", + "crossbeam-utils", +] + +[[package]] +name = "crossbeam-epoch" +version = "0.9.16" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2d2fe95351b870527a5d09bf563ed3c97c0cffb87cf1c78a591bf48bb218d9aa" +dependencies = [ + "autocfg", + "cfg-if", + "crossbeam-utils", + "memoffset", +] + +[[package]] +name = "crossbeam-utils" +version = "0.8.17" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c06d96137f14f244c37f989d9fff8f95e6c18b918e71f36638f8c49112e4c78f" +dependencies = [ + "cfg-if", +] + +[[package]] +name = "deranged" +version = "0.3.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8eb30d70a07a3b04884d2677f06bec33509dc67ca60d92949e5535352d3191dc" +dependencies = [ + "powerfmt", +] + +[[package]] +name = "either" +version = "1.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a26ae43d7bcc3b814de94796a5e736d4029efb0ee900c12e2d54c993ad1a1e07" + +[[package]] +name = "encoding_rs" +version = "0.8.33" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7268b386296a025e474d5140678f75d6de9493ae55a5d709eeb9dd08149945e1" +dependencies = [ + "cfg-if", +] + +[[package]] +name = "flate2" +version = "1.0.28" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "46303f565772937ffe1d394a4fac6f411c6013172fadde9dcdb1e147a086940e" +dependencies = [ + "crc32fast", + "miniz_oxide", +] + [[package]] name = "gulagcleaner" version = "0.1.0" dependencies = [ + "flate2", + "lopdf", +] + +[[package]] +name = "gulagcleaner_python" +version = "0.1.0" +dependencies = [ + "gulagcleaner", "pyo3", ] +[[package]] +name = "gulagcleaner_wasm" +version = "0.5.0" +dependencies = [ + "gulagcleaner", + "wasm-bindgen", +] + [[package]] name = "heck" version = "0.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "95505c38b4572b2d910cecb0281560f54b440a19336cbbcb27bf6ce6adc6f5a8" +[[package]] +name = "iana-time-zone" +version = "0.1.58" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8326b86b6cff230b97d0d312a6c40a60726df3332e721f72a1b035f451663b20" +dependencies = [ + "android_system_properties", + "core-foundation-sys", + "iana-time-zone-haiku", + "js-sys", + "wasm-bindgen", + "windows-core", +] + +[[package]] +name = "iana-time-zone-haiku" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f31827a206f56af32e590ba56d5d2d085f558508192593743f16b2306495269f" +dependencies = [ + "cc", +] + [[package]] name = "indoc" version = "2.0.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1e186cfbae8084e513daff4240b4797e342f988cecda4fb6c939150f96315fd8" +[[package]] +name = "itoa" +version = "1.0.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b1a46d1a171d865aa5f83f92695765caa047a9b4cbae2cbf37dbd613a793fd4c" + +[[package]] +name = "js-sys" +version = "0.3.66" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cee9c64da59eae3b50095c18d3e74f8b73c0b86d2792824ff01bbce68ba229ca" +dependencies = [ + "wasm-bindgen", +] + [[package]] name = "libc" version = "0.2.151" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "302d7ab3130588088d277783b1e2d2e10c9e9e4a16dd9050e6ec93fb3e7048f4" +[[package]] +name = "linked-hash-map" +version = "0.5.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0717cef1bc8b636c6e1c1bbdefc09e6322da8a9321966e8928ef80d20f7f770f" + [[package]] name = "lock_api" version = "0.4.11" @@ -55,6 +245,43 @@ dependencies = [ "scopeguard", ] +[[package]] +name = "log" +version = "0.4.20" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b5e6163cb8c49088c2c36f57875e58ccd8c87c7427f7fbd50ea6710b2f3f2e8f" + +[[package]] +name = "lopdf" +version = "0.31.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "07c8e1b6184b1b32ea5f72f572ebdc40e5da1d2921fa469947ff7c480ad1f85a" +dependencies = [ + "chrono", + "encoding_rs", + "flate2", + "itoa", + "linked-hash-map", + "log", + "md5", + "nom", + "rayon", + "time", + "weezl", +] + +[[package]] +name = "md5" +version = "0.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "490cc448043f947bae3cbee9c203358d62dbee0db12107a74be5c30ccfd09771" + +[[package]] +name = "memchr" +version = "2.6.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f665ee40bc4a3c5590afb1e9677db74a508659dfd71e126420da8274909a0167" + [[package]] name = "memoffset" version = "0.9.0" @@ -64,6 +291,40 @@ dependencies = [ "autocfg", ] +[[package]] +name = "minimal-lexical" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "68354c5c6bd36d73ff3feceb05efa59b6acb7626617f4962be322a825e61f79a" + +[[package]] +name = "miniz_oxide" +version = "0.7.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e7810e0be55b428ada41041c41f32c9f1a42817901b4ccf45fa3d4b6561e74c7" +dependencies = [ + "adler", +] + +[[package]] +name = "nom" +version = "7.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d273983c5a657a70a3e8f2a01329822f3b8c8172b73826411a55751e404a0a4a" +dependencies = [ + "memchr", + "minimal-lexical", +] + +[[package]] +name = "num-traits" +version = "0.2.17" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "39e3200413f237f41ab11ad6d161bc7239c84dcb631773ccd7de3dfe4b5c267c" +dependencies = [ + "autocfg", +] + [[package]] name = "once_cell" version = "1.19.0" @@ -93,6 +354,12 @@ dependencies = [ "windows-targets", ] +[[package]] +name = "powerfmt" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "439ee305def115ba05938db6eb1644ff94165c5ab5e9420d1c1bcedbba909391" + [[package]] name = "proc-macro2" version = "1.0.71" @@ -172,6 +439,26 @@ dependencies = [ "proc-macro2", ] +[[package]] +name = "rayon" +version = "1.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9c27db03db7734835b3f53954b534c91069375ce6ccaa2e065441e07d9b6cdb1" +dependencies = [ + "either", + "rayon-core", +] + +[[package]] +name = "rayon-core" +version = "1.12.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5ce3fb6ad83f861aac485e76e1985cd109d9a3713802152be56c3b1f0e0658ed" +dependencies = [ + "crossbeam-deque", + "crossbeam-utils", +] + [[package]] name = "redox_syscall" version = "0.4.1" @@ -187,6 +474,26 @@ version = "1.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "94143f37725109f92c262ed2cf5e59bce7498c01bcc1502d7b9afe439a4e9f49" +[[package]] +name = "serde" +version = "1.0.193" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "25dd9975e68d0cb5aa1120c288333fc98731bd1dd12f561e468ea4728c042b89" +dependencies = [ + "serde_derive", +] + +[[package]] +name = "serde_derive" +version = "1.0.193" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "43576ca501357b9b071ac53cdc7da8ef0cbd9493d8df094cd821777ea6e894d3" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + [[package]] name = "smallvec" version = "1.11.2" @@ -210,6 +517,35 @@ version = "0.12.12" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "14c39fd04924ca3a864207c66fc2cd7d22d7c016007f9ce846cbb9326331930a" +[[package]] +name = "time" +version = "0.3.31" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f657ba42c3f86e7680e53c8cd3af8abbe56b5491790b46e22e19c0d57463583e" +dependencies = [ + "deranged", + "itoa", + "powerfmt", + "serde", + "time-core", + "time-macros", +] + +[[package]] +name = "time-core" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ef927ca75afb808a4d64dd374f00a2adf8d0fcff8e7b184af886c3c87ec4a3f3" + +[[package]] +name = "time-macros" +version = "0.2.16" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "26197e33420244aeb70c3e8c78376ca46571bc4e701e4791c2cd9f57dcb3a43f" +dependencies = [ + "time-core", +] + [[package]] name = "unicode-ident" version = "1.0.12" @@ -222,6 +558,75 @@ version = "0.2.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c7de7d73e1754487cb58364ee906a499937a0dfabd86bcb980fa99ec8c8fa2ce" +[[package]] +name = "wasm-bindgen" +version = "0.2.89" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0ed0d4f68a3015cc185aff4db9506a015f4b96f95303897bfa23f846db54064e" +dependencies = [ + "cfg-if", + "wasm-bindgen-macro", +] + +[[package]] +name = "wasm-bindgen-backend" +version = "0.2.89" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1b56f625e64f3a1084ded111c4d5f477df9f8c92df113852fa5a374dbda78826" +dependencies = [ + "bumpalo", + "log", + "once_cell", + "proc-macro2", + "quote", + "syn", + "wasm-bindgen-shared", +] + +[[package]] +name = "wasm-bindgen-macro" +version = "0.2.89" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0162dbf37223cd2afce98f3d0785506dcb8d266223983e4b5b525859e6e182b2" +dependencies = [ + "quote", + "wasm-bindgen-macro-support", +] + +[[package]] +name = "wasm-bindgen-macro-support" +version = "0.2.89" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f0eb82fcb7930ae6219a7ecfd55b217f5f0893484b7a13022ebb2b2bf20b5283" +dependencies = [ + "proc-macro2", + "quote", + "syn", + "wasm-bindgen-backend", + "wasm-bindgen-shared", +] + +[[package]] +name = "wasm-bindgen-shared" +version = "0.2.89" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7ab9b36309365056cd639da3134bf87fa8f3d86008abf99e612384a6eecd459f" + +[[package]] +name = "weezl" +version = "0.1.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9193164d4de03a926d909d3bc7c30543cecb35400c02114792c2cae20d5e2dbb" + +[[package]] +name = "windows-core" +version = "0.51.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f1f8cf84f35d2db49a46868f947758c7a1138116f7fac3bc844f43ade1292e64" +dependencies = [ + "windows-targets", +] + [[package]] name = "windows-targets" version = "0.48.5" diff --git a/Cargo.toml b/Cargo.toml index 123e0ad..6f76e1e 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,12 +1,7 @@ -[package] -name = "gulagcleaner" -version = "0.1.0" -edition = "2021" +[workspace] -# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html -[lib] -name = "gulagcleaner_lib" -crate-type = ["cdylib"] -path = "rust/lib.rs" -[dependencies] -pyo3 = { version = "0.20.0", features = ["extension-module"] } \ No newline at end of file +members = [ + "gulagcleaner", + "gulagcleaner_python", + "gulagcleaner_wasm" +] \ No newline at end of file diff --git a/gulagcleaner/Cargo.toml b/gulagcleaner/Cargo.toml new file mode 100644 index 0000000..057ffb3 --- /dev/null +++ b/gulagcleaner/Cargo.toml @@ -0,0 +1,15 @@ +[package] +name = "gulagcleaner" +version = "0.1.0" +edition = "2021" +debuginfo-level = 1 + +# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html + +[lib] +name = "gulagcleaner" +crate-type = ["lib"] + +[dependencies] +flate2 = "1.0.27" +lopdf = "0.31.0" diff --git a/rust/gulagcleaner/gulagcleaner.rs b/gulagcleaner/src/lib.rs similarity index 100% rename from rust/gulagcleaner/gulagcleaner.rs rename to gulagcleaner/src/lib.rs diff --git a/gulagcleaner_python/Cargo.toml b/gulagcleaner_python/Cargo.toml new file mode 100644 index 0000000..b64caaf --- /dev/null +++ b/gulagcleaner_python/Cargo.toml @@ -0,0 +1,14 @@ +[package] +name = "gulagcleaner_python" +version = "0.1.0" +edition = "2021" + +# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html +[lib] +name = "gulagcleaner_python" +crate-type = ["cdylib"] +path = "rust/lib.rs" + +[dependencies] +pyo3 = { version = "0.20.0", features = ["extension-module"] } +gulagcleaner = { path = "../gulagcleaner" } \ No newline at end of file diff --git a/MANIFEST.in b/gulagcleaner_python/MANIFEST.in similarity index 100% rename from MANIFEST.in rename to gulagcleaner_python/MANIFEST.in diff --git a/pyproject.toml b/gulagcleaner_python/pyproject.toml similarity index 95% rename from pyproject.toml rename to gulagcleaner_python/pyproject.toml index b0ff0eb..a118cfa 100644 --- a/pyproject.toml +++ b/gulagcleaner_python/pyproject.toml @@ -1,5 +1,5 @@ [build-system] -requires = ["setuptools", "setuptools-rust"] +requires = ["setuptools", "wheel", "setuptools-rust"] build-backend = "setuptools.build_meta" [project] diff --git a/python/gulagcleaner/__init__.py b/gulagcleaner_python/python/gulagcleaner/__init__.py similarity index 100% rename from python/gulagcleaner/__init__.py rename to gulagcleaner_python/python/gulagcleaner/__init__.py diff --git a/gulagcleaner_python/python/gulagcleaner/__pycache__/__init__.cpython-38.pyc b/gulagcleaner_python/python/gulagcleaner/__pycache__/__init__.cpython-38.pyc new file mode 100644 index 0000000000000000000000000000000000000000..8b86374a8d055a3095ae2bba82c2206c06b2e6c9 GIT binary patch literal 170 zcmWIL<>g`k0x#y)R1p0bL?8o3AjbiSi&=m~3PUi1CZpdI zQ<7 literal 0 HcmV?d00001 diff --git a/gulagcleaner_python/python/gulagcleaner/__pycache__/clean.cpython-38.pyc b/gulagcleaner_python/python/gulagcleaner/__pycache__/clean.cpython-38.pyc new file mode 100644 index 0000000000000000000000000000000000000000..5fa64865f73ca93ec9f0bf75433f4f2e9316efbd GIT binary patch literal 362 zcmY*VOKQU~5FJTrNt$@yD|pibloA5jmTXEk#voivaSZYYeF|Q;Jxs3CrIzi=SLmuU zCWT~Ro@Sn&=A(U*+yUB`_|)GV;D?e+Lk>3R?jAvbVg?$PF$Rh&@c|iEvlmEjMuyiX z784g5Svcvut=p;;$o?C}LB~VALFtMz7PJK z96DQS*%tMiK7n1J`1g7HnD3poE+4w4c6k*{QI$p)t+rQ*><54B+WdT6=_dU{Kg7ip sNo=2BaYy3-vrEKXDzce0^{b^tCTbes0%(mme`-1vj9$~POa)e}KPX^VF8}}l literal 0 HcmV?d00001 diff --git a/gulagcleaner_python/python/gulagcleaner/__pycache__/command_line.cpython-38.pyc b/gulagcleaner_python/python/gulagcleaner/__pycache__/command_line.cpython-38.pyc new file mode 100644 index 0000000000000000000000000000000000000000..0d40d6450f838f31991359c991132a15d4353827 GIT binary patch literal 3616 zcmbVPOOG4J5$<`A96nZ}q?J}{SxH;A>@e|8gdl+vLJ*>?yg`82F}xP+Fj9ySyGc%V z9(4DR(hj(}tc}PQL%HXW9F?DvpD@=10sI$?0LoX*87)_efxtubqpGW`tE;*myt}c{ zV)#1l=h8aI*gpwa|7-w1N7E5H!GsmD*cw4jo2G_ zadXf#xLVYT+kGMdLFz*bts*Vmu?yiq?Uxrm`#A$Hcp{&w3kQ;Y8N6ismSi zK{A|)F@Uy^BXu~-O0X**WhxkD!&qj42(qB(6m|J1)R``7p%$Sk+&`pY(zA<31S}!y zO2+9zj);BrS(tce4x0W5ov?5{T=j@S97njKMnW%v-)58g7r-sqL0!0}ubIAXde9uy z|HQ_YxtzCTci6EdT7RkIO6~m17RR?YPexgoCOk{|EKpkVKuzYcOfv1a48`tLjt(>* zr-}#3Ax~#S9z-W}*r&A=#37qXK2zyL1u=*PhdRPVkV$Pg(dsBwO6pmfh%lM(aTH8& z4hf>@-cPN<#rcce-kG8)G>t}ZG9rTNqqpFqT|m>9(M{Nr-R~Y*OY1Q^Xef7S{n`H1 z-Dgjk>R=g4xBVN11LjYyftO*FnG|O2>;2vSy}Mc}eeW=hLw#>DhginaQk?>Zv%_qf zCilwW6x}F|V_bO{g^BcMhehiq85!8wtt}F=j;_vZm^Qy^6n$Ia>Nlfw6h!(KCKYwB zUbs^k&5DMSvnUwJqNb;*%8JGUB0~2?8@3q9VG@K3ERMrSYTVD!hg!99iXt~MH&bV6 z)uGkRUpWE9^yt2iPYFT{=t$@aU zf|K$rYZ$l=X|K?E7++o1#no-LIv?t7*I7=J2*&_^#5l>|Hs4y0a-MitLlkWG0y=4m21j)_wxxe>uQ41YKc zM^iou68=E)5AN*o6&jS|G!pPMNRVWZmf{rF_1h+*Wh%sJ2z9HVWx}_)LLf8`6CDbi zHYQB$bCNod56yN+D7g+62$awO)jVSMO*tkU?zj(°H(qvrmB8^jq{2HH(zCXvZ=X} zpI`XROF6Eezr{HezV_{tPO@pJSGtd-ri=LbFF>f)=)Q&i^Pho-Ugzas#}8X)65p)kU)0rQJDld6HFD?(-Y|PyHV$N_Qrk z=lySKTi^E;Wp=em-6cA#ZQkKHohQP7sS=>vYAOLA6H^JiNtM7~Q5pWtg11_k{g^GS zW8^C3R`XST(6e&ar+UsQJedgn5MH5(pQ1e3v(*NM!lg%!;-n!XNwv``yHa9Rs8rcL znx>i!3Epb4GtctNF(SwR%I;tN=h?God26_OYB)G=zE{?Z{k(Zwji%uu?ejsSoaT+& z^DI@s)XXIB+}7bF39`8gfNY&W`B~UQr~HurQUwA$@{Lo7ytNmM<`HUB?DML5zHv7} z8G*t=n1%Klm|xjL_*qqUWpVpF2=oVy{rPBwN1wmGOGPog552;S=aJ9%u=6C|4cbaV zWR%YE-TdskN+Hl19nikq?(?E%kiE7kLW2Sl(nFd5JW#&yiUwZg`-3(@*ldp49rED60hu5iWrZaNty0ohPgZ8WN~}#0 z<&srj0jOu_ShwzY);IrLv+6os(75)B?hM9`WjihVnr+*zjoQoZIv%Pp+i>by)o;@} zZ@ubtfNfc>Re$C=>N?IWyy1|f7!LF6yFnDK;vV_x3pupPpYQk14bHCzSKp}JC~UBK zYN7l;V-!5NcxtJN{YLMDMyh>M+?r*`TM9eX%9w}@VeI%^<|K&aaHw9R1uDqbI-^?e cW}J$7ByUlbuL;$GqEMh(UE90h{ob?w3-f)zyZ`_I literal 0 HcmV?d00001 diff --git a/gulagcleaner_python/python/gulagcleaner/__pycache__/decrypt.cpython-38.pyc b/gulagcleaner_python/python/gulagcleaner/__pycache__/decrypt.cpython-38.pyc new file mode 100644 index 0000000000000000000000000000000000000000..2ac2b11522bd04a698944dc486704df6e578e58f GIT binary patch literal 642 zcmah{!AiqG5S`rwjTOa%BHs3BF2#!;iio0kEVWvcP$;3hZKG)tcDF($z1g$B&>sC9 zukq-qzaT=LtVLT99GJ*@9(;?jfZf(PWXt*UKn!=boZ478iM^;M4gupfI z!v$2~22!K_@LFIPXQCMMdLrMA2*At<;ll%I(;ZK zj9L+guAMC>!JR^KpTXDk0+xK`%iedF5O`qO}C;leY>CH&&=<AmP0=QJ<_i; literal 0 HcmV?d00001 diff --git a/gulagcleaner_python/python/gulagcleaner/__pycache__/metadata.cpython-38.pyc b/gulagcleaner_python/python/gulagcleaner/__pycache__/metadata.cpython-38.pyc new file mode 100644 index 0000000000000000000000000000000000000000..e808d4753ee2f1541b31e69c21b1cd31dc58dced GIT binary patch literal 1119 zcmZ8gJ#P~+7`87T4I!1PwgcU)Og$;e4~P&V3IwKtC|#mRkvTgTgYO*KzO;whsa^R8 z3^4Lf_zkx*Wng6K#A_#)rgpEb|P2 zA%-PN@CakX0#><0qkvVPsOhQ~_7wcESwjxWPdp$02=>{;wqeeon<}~K!Ogqog4fWCu zSI&QTo)-t@Cs{h(#f|HQ4qEsysN>D=ULS+^EUb)*+lXMm;Q1-!ZY21 VBgiTm&lANm$zM2$jT533{0Hc6HVyy) literal 0 HcmV?d00001 diff --git a/python/gulagcleaner/clean.py b/gulagcleaner_python/python/gulagcleaner/clean.py similarity index 100% rename from python/gulagcleaner/clean.py rename to gulagcleaner_python/python/gulagcleaner/clean.py diff --git a/python/gulagcleaner/command_line.py b/gulagcleaner_python/python/gulagcleaner/command_line.py similarity index 100% rename from python/gulagcleaner/command_line.py rename to gulagcleaner_python/python/gulagcleaner/command_line.py diff --git a/python/gulagcleaner/decrypt.py b/gulagcleaner_python/python/gulagcleaner/decrypt.py similarity index 100% rename from python/gulagcleaner/decrypt.py rename to gulagcleaner_python/python/gulagcleaner/decrypt.py diff --git a/python/gulagcleaner/metadata.py b/gulagcleaner_python/python/gulagcleaner/metadata.py similarity index 100% rename from python/gulagcleaner/metadata.py rename to gulagcleaner_python/python/gulagcleaner/metadata.py diff --git a/rust/python_binder.rs b/gulagcleaner_python/rust/lib.rs similarity index 56% rename from rust/python_binder.rs rename to gulagcleaner_python/rust/lib.rs index 1235a25..4171b2a 100644 --- a/rust/python_binder.rs +++ b/gulagcleaner_python/rust/lib.rs @@ -1,9 +1,16 @@ use pyo3::prelude::*; - -#[path = "gulagcleaner/gulagcleaner.rs"] mod gulagcleaner; +use gulagcleaner; /// I only need to replace the sum_as_string function with the clean_pdf function, and the arguments to be u8 vectors. Maybe I need to change some types here to pure rust. #[pyfunction] pub fn sum_as_string(a: usize, b: usize) -> PyResult { Ok(gulagcleaner::sum_as_string(a, b)) -} \ No newline at end of file +} + +/// I only need to replace the sum_as_string function with the clean_pdf function +#[pymodule] +fn _lib(_py: Python, m: &PyModule) -> PyResult<()> { + m.add_function(wrap_pyfunction!(sum_as_string, m)?)?; + Ok(()) +} + diff --git a/gulagcleaner_wasm/Cargo.toml b/gulagcleaner_wasm/Cargo.toml new file mode 100644 index 0000000..9d9fb79 --- /dev/null +++ b/gulagcleaner_wasm/Cargo.toml @@ -0,0 +1,13 @@ +[package] +name = "gulagcleaner_wasm" +version = "0.5.0" +edition = "2021" + +# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html + +[lib] +crate-type = ["cdylib"] + +[dependencies] +wasm-bindgen = "0.2" +gulagcleaner = { path = "../gulagcleaner" } \ No newline at end of file diff --git a/gulagcleaner_wasm/src/lib.rs b/gulagcleaner_wasm/src/lib.rs new file mode 100644 index 0000000..f93950a --- /dev/null +++ b/gulagcleaner_wasm/src/lib.rs @@ -0,0 +1,7 @@ +use wasm_bindgen::prelude::*; +use gulagcleaner; + +#[wasm_bindgen] +pub fn sum_as_string(a: usize, b: usize) -> String { + gulagcleaner::sum_as_string(a, b) +} \ No newline at end of file diff --git a/rust/lib.rs b/rust/lib.rs deleted file mode 100644 index b2c7a25..0000000 --- a/rust/lib.rs +++ /dev/null @@ -1,10 +0,0 @@ -use pyo3::prelude::*; - -mod python_binder; - -/// I only need to replace the sum_as_string function with the clean_pdf function -#[pymodule] -fn _lib(_py: Python, m: &PyModule) -> PyResult<()> { - m.add_function(wrap_pyfunction!(python_binder::sum_as_string, m)?)?; - Ok(()) -} diff --git a/rust/wasm_binder.rs b/rust/wasm_binder.rs deleted file mode 100644 index 7a4c807..0000000 --- a/rust/wasm_binder.rs +++ /dev/null @@ -1,2 +0,0 @@ -//It would be nice to abstract the #[wasm_bindgen] or however its called into here, so i can still use the same code for the wasm and the python version. -#[path = "gulagcleaner/gulagcleaner.rs"] mod gulagcleaner; \ No newline at end of file From dc1f94bf70d91eb77dcc43a321c2239f23b146b9 Mon Sep 17 00:00:00 2001 From: YM162 Date: Fri, 22 Dec 2023 21:54:04 +0100 Subject: [PATCH 03/27] CI test --- .github/workflows/CI.yml | 109 +++++++++++++++++++++++++++++++++ gulagcleaner_python/.gitignore | 1 + 2 files changed, 110 insertions(+) create mode 100644 .github/workflows/CI.yml create mode 100644 gulagcleaner_python/.gitignore diff --git a/.github/workflows/CI.yml b/.github/workflows/CI.yml new file mode 100644 index 0000000..d89baa6 --- /dev/null +++ b/.github/workflows/CI.yml @@ -0,0 +1,109 @@ +name: CI + +on: + push: + branches: + - rust_bindings + tags: + - '**' + pull_request: {} + +jobs: + build: + name: build py3.${{ matrix.python-version }} on ${{ matrix.platform || matrix.os }} + needs: + strategy: + fail-fast: false + matrix: + os: + - ubuntu + - macos + - windows + python-version: + - '7' + - '8' + - '9' + include: + - os: ubuntu + platform: linux + - os: windows + ls: dir + + runs-on: ${{ format('{0}-latest', matrix.os) }} + steps: + - uses: actions/checkout@v2 + + - name: move to the gulagcleaner_python directory + run: cd gulagcleaner_python + + - name: set up python + uses: actions/setup-python@v1 + with: + python-version: '3.8' + + - name: set up rust + if: matrix.os != 'ubuntu' + uses: actions-rs/toolchain@v1 + with: + profile: minimal + toolchain: nightly + override: true + + - name: install python dependencies + run: pip install -U setuptools wheel twine cibuildwheel build + + - name: build sdist + if: matrix.os == 'ubuntu' && matrix.python-version == '8' + run: | + pip install -U setuptools-rust + python -m build . --sdist + + - name: build ${{ matrix.platform || matrix.os }} binaries + run: cibuildwheel --output-dir dist + env: + CIBW_BUILD: 'cp3${{ matrix.python-version }}-*' + CIBW_SKIP: '*-win32' + CIBW_PLATFORM: ${{ matrix.platform || matrix.os }} + CIBW_TEST_REQUIRES: 'pytest' + CIBW_TEST_COMMAND: 'pytest {project}/tests -s' + CIBW_ENVIRONMENT: 'PATH="$HOME/.cargo/bin:$PATH"' + CIBW_ENVIRONMENT_WINDOWS: 'PATH="$UserProfile\.cargo\bin;$PATH"' + CIBW_MANYLINUX_X86_64_IMAGE: 'manylinux2014' + CIBW_MANYLINUX_I686_IMAGE: 'manylinux2014' + CIBW_BEFORE_BUILD: > + pip install -U setuptools-rust && + rustup default nightly && + rustup show + CIBW_BEFORE_BUILD_LINUX: > + pip install -U setuptools-rust && + curl https://sh.rustup.rs -sSf | sh -s -- --default-toolchain=nightly --profile=minimal -y && + rustup show + + - name: build windows 32bit binaries + if: matrix.os == 'windows' + run: cibuildwheel --output-dir dist + env: + CIBW_BUILD: 'cp3${{ matrix.python-version }}-win32' + CIBW_PLATFORM: windows + CIBW_TEST_REQUIRES: 'pytest' + CIBW_TEST_COMMAND: 'pytest {project}/tests -s' + CIBW_ENVIRONMENT: 'PATH="$UserProfile\.cargo\bin;$PATH"' + CIBW_BEFORE_BUILD: > + pip install -U setuptools-rust && + rustup toolchain install nightly-i686-pc-windows-msvc && + rustup default nightly-i686-pc-windows-msvc && + rustup override set nightly-i686-pc-windows-msvc && + rustup show + + - name: list dist files + run: ${{ matrix.ls || 'ls -lh' }} dist/ + + # - name: twine check + # run: twine check dist/* + + # - name: upload to pypi + # if: startsWith(github.ref, 'refs/tags/') + # run: twine upload dist/* + # env: + # TWINE_USERNAME: __token__ + # TWINE_PASSWORD: ${{ secrets.pypi_token }} \ No newline at end of file diff --git a/gulagcleaner_python/.gitignore b/gulagcleaner_python/.gitignore new file mode 100644 index 0000000..d163863 --- /dev/null +++ b/gulagcleaner_python/.gitignore @@ -0,0 +1 @@ +build/ \ No newline at end of file From 1872e3ce698c189dba417904557ca002e9a05938 Mon Sep 17 00:00:00 2001 From: YM162 Date: Fri, 22 Dec 2023 21:55:54 +0100 Subject: [PATCH 04/27] Fix CI --- .github/workflows/CI.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/workflows/CI.yml b/.github/workflows/CI.yml index d89baa6..888e84e 100644 --- a/.github/workflows/CI.yml +++ b/.github/workflows/CI.yml @@ -11,7 +11,6 @@ on: jobs: build: name: build py3.${{ matrix.python-version }} on ${{ matrix.platform || matrix.os }} - needs: strategy: fail-fast: false matrix: From 242d853bb692a1b18719603258bbeecfc7c2adaa Mon Sep 17 00:00:00 2001 From: YM162 Date: Fri, 22 Dec 2023 22:06:42 +0100 Subject: [PATCH 05/27] Fix CI? --- .github/workflows/CI.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/CI.yml b/.github/workflows/CI.yml index 888e84e..23868cc 100644 --- a/.github/workflows/CI.yml +++ b/.github/workflows/CI.yml @@ -29,12 +29,12 @@ jobs: ls: dir runs-on: ${{ format('{0}-latest', matrix.os) }} + defaults: + run: + working-directory: gulagcleaner_python steps: - uses: actions/checkout@v2 - - name: move to the gulagcleaner_python directory - run: cd gulagcleaner_python - - name: set up python uses: actions/setup-python@v1 with: From f510cbfb75437e566c267b1026abc46f6dc7da58 Mon Sep 17 00:00:00 2001 From: YM162 Date: Fri, 22 Dec 2023 22:17:09 +0100 Subject: [PATCH 06/27] Fix CI windows/macos --- .github/workflows/CI.yml | 4 ---- 1 file changed, 4 deletions(-) diff --git a/.github/workflows/CI.yml b/.github/workflows/CI.yml index 23868cc..1bdef7f 100644 --- a/.github/workflows/CI.yml +++ b/.github/workflows/CI.yml @@ -63,8 +63,6 @@ jobs: CIBW_BUILD: 'cp3${{ matrix.python-version }}-*' CIBW_SKIP: '*-win32' CIBW_PLATFORM: ${{ matrix.platform || matrix.os }} - CIBW_TEST_REQUIRES: 'pytest' - CIBW_TEST_COMMAND: 'pytest {project}/tests -s' CIBW_ENVIRONMENT: 'PATH="$HOME/.cargo/bin:$PATH"' CIBW_ENVIRONMENT_WINDOWS: 'PATH="$UserProfile\.cargo\bin;$PATH"' CIBW_MANYLINUX_X86_64_IMAGE: 'manylinux2014' @@ -84,8 +82,6 @@ jobs: env: CIBW_BUILD: 'cp3${{ matrix.python-version }}-win32' CIBW_PLATFORM: windows - CIBW_TEST_REQUIRES: 'pytest' - CIBW_TEST_COMMAND: 'pytest {project}/tests -s' CIBW_ENVIRONMENT: 'PATH="$UserProfile\.cargo\bin;$PATH"' CIBW_BEFORE_BUILD: > pip install -U setuptools-rust && From b5e644e7b31c9c01aec0888192b46834b9f0ac28 Mon Sep 17 00:00:00 2001 From: YM162 Date: Fri, 22 Dec 2023 22:40:27 +0100 Subject: [PATCH 07/27] CI Fixed --- .github/workflows/CI.yml | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/.github/workflows/CI.yml b/.github/workflows/CI.yml index 1bdef7f..5afda19 100644 --- a/.github/workflows/CI.yml +++ b/.github/workflows/CI.yml @@ -29,9 +29,6 @@ jobs: ls: dir runs-on: ${{ format('{0}-latest', matrix.os) }} - defaults: - run: - working-directory: gulagcleaner_python steps: - uses: actions/checkout@v2 @@ -58,7 +55,7 @@ jobs: python -m build . --sdist - name: build ${{ matrix.platform || matrix.os }} binaries - run: cibuildwheel --output-dir dist + run: cibuildwheel gulagcleaner_python --output-dir dist env: CIBW_BUILD: 'cp3${{ matrix.python-version }}-*' CIBW_SKIP: '*-win32' From 5c7c5da475302d376834a8a57799fcf3e52ba06f Mon Sep 17 00:00:00 2001 From: YM162 Date: Fri, 22 Dec 2023 22:42:20 +0100 Subject: [PATCH 08/27] CI Fixed --- .github/workflows/CI.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/CI.yml b/.github/workflows/CI.yml index 5afda19..880e530 100644 --- a/.github/workflows/CI.yml +++ b/.github/workflows/CI.yml @@ -49,6 +49,7 @@ jobs: run: pip install -U setuptools wheel twine cibuildwheel build - name: build sdist + working-directory: gulagcleaner_python if: matrix.os == 'ubuntu' && matrix.python-version == '8' run: | pip install -U setuptools-rust From 72ce2bd6a73d8b7445711b0a269e58baf5e78d23 Mon Sep 17 00:00:00 2001 From: YM162 Date: Fri, 22 Dec 2023 22:46:04 +0100 Subject: [PATCH 09/27] Typo in CI --- .github/workflows/CI.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/CI.yml b/.github/workflows/CI.yml index 880e530..7c8ca6a 100644 --- a/.github/workflows/CI.yml +++ b/.github/workflows/CI.yml @@ -76,7 +76,7 @@ jobs: - name: build windows 32bit binaries if: matrix.os == 'windows' - run: cibuildwheel --output-dir dist + run: cibuildwheel gulagcleaner_python --output-dir dist env: CIBW_BUILD: 'cp3${{ matrix.python-version }}-win32' CIBW_PLATFORM: windows From 096afa2d3e0fbd761087b4df9b31208b51b7eb51 Mon Sep 17 00:00:00 2001 From: YM162 Date: Sat, 23 Dec 2023 00:17:38 +0100 Subject: [PATCH 10/27] Skip *-musllinux_i686 build --- .github/workflows/CI.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/CI.yml b/.github/workflows/CI.yml index 7c8ca6a..16cc94d 100644 --- a/.github/workflows/CI.yml +++ b/.github/workflows/CI.yml @@ -59,7 +59,7 @@ jobs: run: cibuildwheel gulagcleaner_python --output-dir dist env: CIBW_BUILD: 'cp3${{ matrix.python-version }}-*' - CIBW_SKIP: '*-win32' + CIBW_SKIP: '*-win32 *-musllinux_i686' CIBW_PLATFORM: ${{ matrix.platform || matrix.os }} CIBW_ENVIRONMENT: 'PATH="$HOME/.cargo/bin:$PATH"' CIBW_ENVIRONMENT_WINDOWS: 'PATH="$UserProfile\.cargo\bin;$PATH"' From 2fb1b870c553f95907ead8eeb76e8d811c182c8d Mon Sep 17 00:00:00 2001 From: YM162 Date: Sat, 23 Dec 2023 01:07:54 +0100 Subject: [PATCH 11/27] Changed workflow to pypi_publish on main branch push. --- .github/workflows/{CI.yml => pypi_publish.yml} | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) rename .github/workflows/{CI.yml => pypi_publish.yml} (90%) diff --git a/.github/workflows/CI.yml b/.github/workflows/pypi_publish.yml similarity index 90% rename from .github/workflows/CI.yml rename to .github/workflows/pypi_publish.yml index 16cc94d..c8d0c3d 100644 --- a/.github/workflows/CI.yml +++ b/.github/workflows/pypi_publish.yml @@ -3,7 +3,7 @@ name: CI on: push: branches: - - rust_bindings + - main tags: - '**' pull_request: {} @@ -91,12 +91,12 @@ jobs: - name: list dist files run: ${{ matrix.ls || 'ls -lh' }} dist/ - # - name: twine check - # run: twine check dist/* + - name: twine check + run: twine check dist/* - # - name: upload to pypi - # if: startsWith(github.ref, 'refs/tags/') - # run: twine upload dist/* - # env: - # TWINE_USERNAME: __token__ - # TWINE_PASSWORD: ${{ secrets.pypi_token }} \ No newline at end of file + - name: upload to pypi + if: startsWith(github.ref, 'refs/tags/') + run: twine upload dist/* + env: + TWINE_USERNAME: __token__ + TWINE_PASSWORD: ${{ secrets.pypi_token }} \ No newline at end of file From c14af2b428a83d1281bae97c75f7ebd53a09e607 Mon Sep 17 00:00:00 2001 From: YM162 Date: Sat, 23 Dec 2023 01:44:50 +0100 Subject: [PATCH 12/27] Added the publish scripts --- .github/workflows/pypi_publish.yml | 2 +- .github/workflows/wasm_publish.yml | 29 +++++++++++++++++++++++++++++ 2 files changed, 30 insertions(+), 1 deletion(-) create mode 100644 .github/workflows/wasm_publish.yml diff --git a/.github/workflows/pypi_publish.yml b/.github/workflows/pypi_publish.yml index c8d0c3d..5d163c5 100644 --- a/.github/workflows/pypi_publish.yml +++ b/.github/workflows/pypi_publish.yml @@ -1,4 +1,4 @@ -name: CI +name: Publish to PyPI on: push: diff --git a/.github/workflows/wasm_publish.yml b/.github/workflows/wasm_publish.yml new file mode 100644 index 0000000..3eecd84 --- /dev/null +++ b/.github/workflows/wasm_publish.yml @@ -0,0 +1,29 @@ +name: Build WASM and publish in the WASM_build branch + +on: + push: + branches: + - rust_bindings + +jobs: + build: + runs-on: ubuntu-latest + name: Build and Push + steps: + - name: git-checkout + uses: actions/checkout@v2 + + - name: install wasm-pack + run: curl https://rustwasm.github.io/wasm-pack/installer/init.sh -sSf | sh + + - name: build wasm + run: wasm-pack build gulagcleaner_wasm --target web --release --no-typescript -d ../WASM_build + + - name: push to the WASM_build branch + uses: s0/git-publish-subdir-action@develop + env: + REPO: self + BRANCH: WASM_build # The branch name where you want to push the assets + FOLDER: WASM_build # The directory where your assets are generated + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # GitHub will automatically add this - you don't need to bother getting a token + MESSAGE: "Build: ({sha}) {msg}" # The commit message \ No newline at end of file From 129a1eab526f27312a8d1e0dfec5a648b7773a1c Mon Sep 17 00:00:00 2001 From: YM162 Date: Sat, 23 Dec 2023 01:47:52 +0100 Subject: [PATCH 13/27] Fixed wasm_publish script --- .github/workflows/wasm_publish.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/wasm_publish.yml b/.github/workflows/wasm_publish.yml index 3eecd84..96818a8 100644 --- a/.github/workflows/wasm_publish.yml +++ b/.github/workflows/wasm_publish.yml @@ -24,6 +24,6 @@ jobs: env: REPO: self BRANCH: WASM_build # The branch name where you want to push the assets - FOLDER: WASM_build # The directory where your assets are generated + FOLDER: gulagcleaner_wasm/WASM_build # The directory where your assets are generated GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # GitHub will automatically add this - you don't need to bother getting a token MESSAGE: "Build: ({sha}) {msg}" # The commit message \ No newline at end of file From 0b54435f4739588ad1de16b146ce1f80cb55f7ed Mon Sep 17 00:00:00 2001 From: YM162 Date: Sat, 23 Dec 2023 01:51:27 +0100 Subject: [PATCH 14/27] Fixed wasm_publish script --- .github/workflows/wasm_publish.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/wasm_publish.yml b/.github/workflows/wasm_publish.yml index 96818a8..0a47a1f 100644 --- a/.github/workflows/wasm_publish.yml +++ b/.github/workflows/wasm_publish.yml @@ -17,7 +17,7 @@ jobs: run: curl https://rustwasm.github.io/wasm-pack/installer/init.sh -sSf | sh - name: build wasm - run: wasm-pack build gulagcleaner_wasm --target web --release --no-typescript -d ../WASM_build + run: wasm-pack build gulagcleaner_wasm --target web --release --no-typescript -d WASM_build - name: push to the WASM_build branch uses: s0/git-publish-subdir-action@develop From 6eb416be8e90dfecf3b32a3c05bf30186e10e2e0 Mon Sep 17 00:00:00 2001 From: YM162 Date: Sat, 23 Dec 2023 01:56:25 +0100 Subject: [PATCH 15/27] Removed auto-gitignore on wasm-pack --- .github/workflows/wasm_publish.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.github/workflows/wasm_publish.yml b/.github/workflows/wasm_publish.yml index 0a47a1f..1879252 100644 --- a/.github/workflows/wasm_publish.yml +++ b/.github/workflows/wasm_publish.yml @@ -19,6 +19,9 @@ jobs: - name: build wasm run: wasm-pack build gulagcleaner_wasm --target web --release --no-typescript -d WASM_build + - name: remove gitignore + run: rm gulagcleaner_wasm/WASM_build/.gitignore + - name: push to the WASM_build branch uses: s0/git-publish-subdir-action@develop env: From d8f14c0f022a0d7379860163d475837394bfd170 Mon Sep 17 00:00:00 2001 From: YM162 Date: Sat, 23 Dec 2023 02:08:54 +0100 Subject: [PATCH 16/27] Added descriptions to all sub-packages. --- .github/workflows/wasm_publish.yml | 2 +- Cargo.lock | 6 +++--- gulagcleaner/Cargo.toml | 10 ++++++++-- gulagcleaner_python/Cargo.toml | 9 ++++++++- gulagcleaner_python/pyproject.toml | 8 ++++---- gulagcleaner_wasm/Cargo.toml | 10 +++++++++- 6 files changed, 33 insertions(+), 12 deletions(-) diff --git a/.github/workflows/wasm_publish.yml b/.github/workflows/wasm_publish.yml index 1879252..02e251c 100644 --- a/.github/workflows/wasm_publish.yml +++ b/.github/workflows/wasm_publish.yml @@ -3,7 +3,7 @@ name: Build WASM and publish in the WASM_build branch on: push: branches: - - rust_bindings + - main jobs: build: diff --git a/Cargo.lock b/Cargo.lock index 6d990ce..f73aeb8 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -151,7 +151,7 @@ dependencies = [ [[package]] name = "gulagcleaner" -version = "0.1.0" +version = "0.10.0" dependencies = [ "flate2", "lopdf", @@ -159,7 +159,7 @@ dependencies = [ [[package]] name = "gulagcleaner_python" -version = "0.1.0" +version = "0.10.0" dependencies = [ "gulagcleaner", "pyo3", @@ -167,7 +167,7 @@ dependencies = [ [[package]] name = "gulagcleaner_wasm" -version = "0.5.0" +version = "0.10.0" dependencies = [ "gulagcleaner", "wasm-bindgen", diff --git a/gulagcleaner/Cargo.toml b/gulagcleaner/Cargo.toml index 057ffb3..77a2388 100644 --- a/gulagcleaner/Cargo.toml +++ b/gulagcleaner/Cargo.toml @@ -1,8 +1,14 @@ [package] name = "gulagcleaner" -version = "0.1.0" +version = "0.10.0" edition = "2021" -debuginfo-level = 1 +authors = ["YM162 "] +description = "Ad removal tool for PDFs." +readme = "../README.md" +homepage = "https://github.com/YM162/gulag-cleaner-cli" +repository = "https://github.com/YM162/gulag-cleaner-cli.git" +license-file = "../LICENSE" +keywords = ["wuolah", "pdf", "ads", "advertisments", "cleaner", "gulagcleaner"] # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html diff --git a/gulagcleaner_python/Cargo.toml b/gulagcleaner_python/Cargo.toml index b64caaf..6337e42 100644 --- a/gulagcleaner_python/Cargo.toml +++ b/gulagcleaner_python/Cargo.toml @@ -1,7 +1,14 @@ [package] name = "gulagcleaner_python" -version = "0.1.0" +version = "0.10.0" edition = "2021" +authors = ["YM162 "] +description = "Ad removal tool for PDFs." +readme = "../README.md" +homepage = "https://github.com/YM162/gulag-cleaner-cli" +repository = "https://github.com/YM162/gulag-cleaner-cli.git" +license-file = "../LICENSE" +keywords = ["wuolah", "pdf", "ads", "advertisments", "cleaner", "gulagcleaner"] # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html [lib] diff --git a/gulagcleaner_python/pyproject.toml b/gulagcleaner_python/pyproject.toml index a118cfa..47ca0b1 100644 --- a/gulagcleaner_python/pyproject.toml +++ b/gulagcleaner_python/pyproject.toml @@ -5,14 +5,14 @@ build-backend = "setuptools.build_meta" [project] name = "gulagcleaner" version = "0.0.1" -description = "Ad removal tool for PDFs written in python." +description = "Ad removal tool for PDFs." authors = [ {name = "YM162", email = "david.fontaneda16@gmail.com"}] -readme = "README.md" +readme = "../README.md" dependencies = [ - "pikepdf>=5.1.2","pdfminer.six>=20220524","pdfrw>=0.4" + "pikepdf>=5.1.2","pdfminer.six>=20220524" ] -license = {file = "LICENSE"} +license = {file = "../LICENSE"} classifiers = ["Programming Language :: Python :: 3", "License :: OSI Approved :: MIT License", "Operating System :: OS Independent"] diff --git a/gulagcleaner_wasm/Cargo.toml b/gulagcleaner_wasm/Cargo.toml index 9d9fb79..d24d3de 100644 --- a/gulagcleaner_wasm/Cargo.toml +++ b/gulagcleaner_wasm/Cargo.toml @@ -1,7 +1,15 @@ [package] name = "gulagcleaner_wasm" -version = "0.5.0" +version = "0.10.0" edition = "2021" +authors = ["YM162 "] +description = "Ad removal tool for PDFs." +readme = "../README.md" +homepage = "https://github.com/YM162/gulag-cleaner-cli" +repository = "https://github.com/YM162/gulag-cleaner-cli.git" +license-file = "../LICENSE" +keywords = ["wuolah", "pdf", "ads", "advertisments", "cleaner", "gulagcleaner"] + # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html From 83dc88e2c8655d481c983351f4b00354ab1a91c2 Mon Sep 17 00:00:00 2001 From: YM162 Date: Sat, 23 Dec 2023 02:12:47 +0100 Subject: [PATCH 17/27] Changed function name to clean_pdf --- gulagcleaner/src/lib.rs | 2 +- gulagcleaner_python/python/gulagcleaner/clean.py | 4 ++-- gulagcleaner_python/rust/lib.rs | 6 +++--- gulagcleaner_wasm/src/lib.rs | 4 ++-- 4 files changed, 8 insertions(+), 8 deletions(-) diff --git a/gulagcleaner/src/lib.rs b/gulagcleaner/src/lib.rs index f07cde7..e4c0e86 100644 --- a/gulagcleaner/src/lib.rs +++ b/gulagcleaner/src/lib.rs @@ -1,5 +1,5 @@ //Here I should place my gulagcleaner-rust functions, and then call clean_pdf from python_binder.rs -pub fn sum_as_string(a: usize, b: usize) -> String { +pub fn clean_pdf(a: usize, b: usize) -> String { (a + b).to_string() } \ No newline at end of file diff --git a/gulagcleaner_python/python/gulagcleaner/clean.py b/gulagcleaner_python/python/gulagcleaner/clean.py index 46f5ea8..19f70a2 100644 --- a/gulagcleaner_python/python/gulagcleaner/clean.py +++ b/gulagcleaner_python/python/gulagcleaner/clean.py @@ -1,4 +1,4 @@ -from ._lib import sum_as_string # export public parts of the binary extension +from ._lib import clean_pdf # export public parts of the binary extension #Here there should only be a function clean_pdf(pdf_path, output_path, force_naive) #that calls the rust function and then saves the pdf in the given output_path. @@ -11,4 +11,4 @@ # """ def clean_pdf(pdf_path, output_path, force_naive): - return sum_as_string(10,6) \ No newline at end of file + return clean_pdf(10,6) \ No newline at end of file diff --git a/gulagcleaner_python/rust/lib.rs b/gulagcleaner_python/rust/lib.rs index 4171b2a..a70dc8a 100644 --- a/gulagcleaner_python/rust/lib.rs +++ b/gulagcleaner_python/rust/lib.rs @@ -3,14 +3,14 @@ use gulagcleaner; /// I only need to replace the sum_as_string function with the clean_pdf function, and the arguments to be u8 vectors. Maybe I need to change some types here to pure rust. #[pyfunction] -pub fn sum_as_string(a: usize, b: usize) -> PyResult { - Ok(gulagcleaner::sum_as_string(a, b)) +pub fn clean_pdf(a: usize, b: usize) -> PyResult { + Ok(gulagcleaner::clean_pdf(a, b)) } /// I only need to replace the sum_as_string function with the clean_pdf function #[pymodule] fn _lib(_py: Python, m: &PyModule) -> PyResult<()> { - m.add_function(wrap_pyfunction!(sum_as_string, m)?)?; + m.add_function(wrap_pyfunction!(clean_pdf, m)?)?; Ok(()) } diff --git a/gulagcleaner_wasm/src/lib.rs b/gulagcleaner_wasm/src/lib.rs index f93950a..71deef6 100644 --- a/gulagcleaner_wasm/src/lib.rs +++ b/gulagcleaner_wasm/src/lib.rs @@ -2,6 +2,6 @@ use wasm_bindgen::prelude::*; use gulagcleaner; #[wasm_bindgen] -pub fn sum_as_string(a: usize, b: usize) -> String { - gulagcleaner::sum_as_string(a, b) +pub fn clean_pdf(a: usize, b: usize) -> String { + gulagcleaner::clean_pdf(a, b) } \ No newline at end of file From 40dcffdc9f09affb4d2f358859c4539b9fdf004d Mon Sep 17 00:00:00 2001 From: YM162 Date: Sat, 23 Dec 2023 03:43:30 +0100 Subject: [PATCH 18/27] Added the gulagcleaner code --- Cargo.lock | 14 +- Cargo.toml | 4 +- gulagcleaner/src/lib.rs | 5 - gulagcleaner_python/Cargo.toml | 2 +- gulagcleaner_python/LICENSE | 1347 +++++++++++++++++ gulagcleaner_python/README.md | 71 + gulagcleaner_python/pyproject.toml | 4 +- .../__pycache__/clean.cpython-38.pyc | Bin 362 -> 1383 bytes .../__pycache__/command_line.cpython-38.pyc | Bin 3616 -> 3621 bytes .../__pycache__/decrypt.cpython-38.pyc | Bin 642 -> 642 bytes .../python/gulagcleaner/clean.py | 40 +- .../python/gulagcleaner/command_line.py | 8 +- gulagcleaner_python/rust/lib.rs | 5 +- {gulagcleaner => gulagcleaner_rs}/Cargo.toml | 5 +- gulagcleaner_rs/LICENSE | 1347 +++++++++++++++++ gulagcleaner_rs/src/lib.rs | 301 ++++ gulagcleaner_rs/src/method.rs | 49 + gulagcleaner_rs/src/page_type.rs | 90 ++ gulagcleaner_wasm/Cargo.toml | 2 +- gulagcleaner_wasm/LICENSE | 1347 +++++++++++++++++ gulagcleaner_wasm/src/lib.rs | 6 +- 21 files changed, 4604 insertions(+), 43 deletions(-) delete mode 100644 gulagcleaner/src/lib.rs create mode 100644 gulagcleaner_python/LICENSE create mode 100644 gulagcleaner_python/README.md rename {gulagcleaner => gulagcleaner_rs}/Cargo.toml (89%) create mode 100644 gulagcleaner_rs/LICENSE create mode 100644 gulagcleaner_rs/src/lib.rs create mode 100644 gulagcleaner_rs/src/method.rs create mode 100644 gulagcleaner_rs/src/page_type.rs create mode 100644 gulagcleaner_wasm/LICENSE diff --git a/Cargo.lock b/Cargo.lock index f73aeb8..d12edfe 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -150,26 +150,26 @@ dependencies = [ ] [[package]] -name = "gulagcleaner" +name = "gulagcleaner_python" version = "0.10.0" dependencies = [ - "flate2", - "lopdf", + "gulagcleaner_rs", + "pyo3", ] [[package]] -name = "gulagcleaner_python" +name = "gulagcleaner_rs" version = "0.10.0" dependencies = [ - "gulagcleaner", - "pyo3", + "flate2", + "lopdf", ] [[package]] name = "gulagcleaner_wasm" version = "0.10.0" dependencies = [ - "gulagcleaner", + "gulagcleaner_rs", "wasm-bindgen", ] diff --git a/Cargo.toml b/Cargo.toml index 6f76e1e..b3f582a 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,7 +1,7 @@ [workspace] - +resolver = "2" members = [ - "gulagcleaner", + "gulagcleaner_rs", "gulagcleaner_python", "gulagcleaner_wasm" ] \ No newline at end of file diff --git a/gulagcleaner/src/lib.rs b/gulagcleaner/src/lib.rs deleted file mode 100644 index e4c0e86..0000000 --- a/gulagcleaner/src/lib.rs +++ /dev/null @@ -1,5 +0,0 @@ -//Here I should place my gulagcleaner-rust functions, and then call clean_pdf from python_binder.rs - -pub fn clean_pdf(a: usize, b: usize) -> String { - (a + b).to_string() -} \ No newline at end of file diff --git a/gulagcleaner_python/Cargo.toml b/gulagcleaner_python/Cargo.toml index 6337e42..29fec1d 100644 --- a/gulagcleaner_python/Cargo.toml +++ b/gulagcleaner_python/Cargo.toml @@ -18,4 +18,4 @@ path = "rust/lib.rs" [dependencies] pyo3 = { version = "0.20.0", features = ["extension-module"] } -gulagcleaner = { path = "../gulagcleaner" } \ No newline at end of file +gulagcleaner_rs = { path = "../gulagcleaner_rs" } \ No newline at end of file diff --git a/gulagcleaner_python/LICENSE b/gulagcleaner_python/LICENSE new file mode 100644 index 0000000..ca40b21 --- /dev/null +++ b/gulagcleaner_python/LICENSE @@ -0,0 +1,1347 @@ + GNU GENERAL PUBLIC LICENSE + Version 3, 29 June 2007 + + Copyright (C) 2007 Free Software Foundation, Inc. + Everyone is permitted to copy and distribute verbatim copies + of this license document, but changing it is not allowed. + + Preamble + + The GNU General Public License is a free, copyleft license for +software and other kinds of works. + + The licenses for most software and other practical works are designed +to take away your freedom to share and change the works. By contrast, +the GNU General Public License is intended to guarantee your freedom to +share and change all versions of a program--to make sure it remains free +software for all its users. We, the Free Software Foundation, use the +GNU General Public License for most of our software; it applies also to +any other work released this way by its authors. You can apply it to +your programs, too. + + When we speak of free software, we are referring to freedom, not +price. Our General Public Licenses are designed to make sure that you +have the freedom to distribute copies of free software (and charge for +them if you wish), that you receive source code or can get it if you +want it, that you can change the software or use pieces of it in new +free programs, and that you know you can do these things. + + To protect your rights, we need to prevent others from denying you +these rights or asking you to surrender the rights. Therefore, you have +certain responsibilities if you distribute copies of the software, or if +you modify it: responsibilities to respect the freedom of others. + + For example, if you distribute copies of such a program, whether +gratis or for a fee, you must pass on to the recipients the same +freedoms that you received. You must make sure that they, too, receive +or can get the source code. And you must show them these terms so they +know their rights. + + Developers that use the GNU GPL protect your rights with two steps: +(1) assert copyright on the software, and (2) offer you this License +giving you legal permission to copy, distribute and/or modify it. + + For the developers' and authors' protection, the GPL clearly explains +that there is no warranty for this free software. For both users' and +authors' sake, the GPL requires that modified versions be marked as +changed, so that their problems will not be attributed erroneously to +authors of previous versions. + + Some devices are designed to deny users access to install or run +modified versions of the software inside them, although the manufacturer +can do so. This is fundamentally incompatible with the aim of +protecting users' freedom to change the software. The systematic +pattern of such abuse occurs in the area of products for individuals to +use, which is precisely where it is most unacceptable. Therefore, we +have designed this version of the GPL to prohibit the practice for those +products. If such problems arise substantially in other domains, we +stand ready to extend this provision to those domains in future versions +of the GPL, as needed to protect the freedom of users. + + Finally, every program is threatened constantly by software patents. +States should not allow patents to restrict development and use of +software on general-purpose computers, but in those that do, we wish to +avoid the special danger that patents applied to a free program could +make it effectively proprietary. To prevent this, the GPL assures that +patents cannot be used to render the program non-free. + + The precise terms and conditions for copying, distribution and +modification follow. + + TERMS AND CONDITIONS + + 0. Definitions. + + "This License" refers to version 3 of the GNU General Public License. + + "Copyright" also means copyright-like laws that apply to other kinds of +works, such as semiconductor masks. + + "The Program" refers to any copyrightable work licensed under this +License. Each licensee is addressed as "you". "Licensees" and +"recipients" may be individuals or organizations. + + To "modify" a work means to copy from or adapt all or part of the work +in a fashion requiring copyright permission, other than the making of an +exact copy. The resulting work is called a "modified version" of the +earlier work or a work "based on" the earlier work. + + A "covered work" means either the unmodified Program or a work based +on the Program. + + To "propagate" a work means to do anything with it that, without +permission, would make you directly or secondarily liable for +infringement under applicable copyright law, except executing it on a +computer or modifying a private copy. Propagation includes copying, +distribution (with or without modification), making available to the +public, and in some countries other activities as well. + + To "convey" a work means any kind of propagation that enables other +parties to make or receive copies. Mere interaction with a user through +a computer network, with no transfer of a copy, is not conveying. + + An interactive user interface displays "Appropriate Legal Notices" +to the extent that it includes a convenient and prominently visible +feature that (1) displays an appropriate copyright notice, and (2) +tells the user that there is no warranty for the work (except to the +extent that warranties are provided), that licensees may convey the +work under this License, and how to view a copy of this License. If +the interface presents a list of user commands or options, such as a +menu, a prominent item in the list meets this criterion. + + 1. Source Code. + + The "source code" for a work means the preferred form of the work +for making modifications to it. "Object code" means any non-source +form of a work. + + A "Standard Interface" means an interface that either is an official +standard defined by a recognized standards body, or, in the case of +interfaces specified for a particular programming language, one that +is widely used among developers working in that language. + + The "System Libraries" of an executable work include anything, other +than the work as a whole, that (a) is included in the normal form of +packaging a Major Component, but which is not part of that Major +Component, and (b) serves only to enable use of the work with that +Major Component, or to implement a Standard Interface for which an +implementation is available to the public in source code form. A +"Major Component", in this context, means a major essential component +(kernel, window system, and so on) of the specific operating system +(if any) on which the executable work runs, or a compiler used to +produce the work, or an object code interpreter used to run it. + + The "Corresponding Source" for a work in object code form means all +the source code needed to generate, install, and (for an executable +work) run the object code and to modify the work, including scripts to +control those activities. However, it does not include the work's +System Libraries, or general-purpose tools or generally available free +programs which are used unmodified in performing those activities but +which are not part of the work. For example, Corresponding Source +includes interface definition files associated with source files for +the work, and the source code for shared libraries and dynamically +linked subprograms that the work is specifically designed to require, +such as by intimate data communication or control flow between those +subprograms and other parts of the work. + + The Corresponding Source need not include anything that users +can regenerate automatically from other parts of the Corresponding +Source. + + The Corresponding Source for a work in source code form is that +same work. + + 2. Basic Permissions. + + All rights granted under this License are granted for the term of +copyright on the Program, and are irrevocable provided the stated +conditions are met. This License explicitly affirms your unlimited +permission to run the unmodified Program. The output from running a +covered work is covered by this License only if the output, given its +content, constitutes a covered work. This License acknowledges your +rights of fair use or other equivalent, as provided by copyright law. + + You may make, run and propagate covered works that you do not +convey, without conditions so long as your license otherwise remains +in force. You may convey covered works to others for the sole purpose +of having them make modifications exclusively for you, or provide you +with facilities for running those works, provided that you comply with +the terms of this License in conveying all material for which you do +not control copyright. Those thus making or running the covered works +for you must do so exclusively on your behalf, under your direction +and control, on terms that prohibit them from making any copies of +your copyrighted material outside their relationship with you. + + Conveying under any other circumstances is permitted solely under +the conditions stated below. Sublicensing is not allowed; section 10 +makes it unnecessary. + + 3. Protecting Users' Legal Rights From Anti-Circumvention Law. + + No covered work shall be deemed part of an effective technological +measure under any applicable law fulfilling obligations under article +11 of the WIPO copyright treaty adopted on 20 December 1996, or +similar laws prohibiting or restricting circumvention of such +measures. + + When you convey a covered work, you waive any legal power to forbid +circumvention of technological measures to the extent such circumvention +is effected by exercising rights under this License with respect to +the covered work, and you disclaim any intention to limit operation or +modification of the work as a means of enforcing, against the work's +users, your or third parties' legal rights to forbid circumvention of +technological measures. + + 4. Conveying Verbatim Copies. + + You may convey verbatim copies of the Program's source code as you +receive it, in any medium, provided that you conspicuously and +appropriately publish on each copy an appropriate copyright notice; +keep intact all notices stating that this License and any +non-permissive terms added in accord with section 7 apply to the code; +keep intact all notices of the absence of any warranty; and give all +recipients a copy of this License along with the Program. + + You may charge any price or no price for each copy that you convey, +and you may offer support or warranty protection for a fee. + + 5. Conveying Modified Source Versions. + + You may convey a work based on the Program, or the modifications to +produce it from the Program, in the form of source code under the +terms of section 4, provided that you also meet all of these conditions: + + a) The work must carry prominent notices stating that you modified + it, and giving a relevant date. + + b) The work must carry prominent notices stating that it is + released under this License and any conditions added under section + 7. This requirement modifies the requirement in section 4 to + "keep intact all notices". + + c) You must license the entire work, as a whole, under this + License to anyone who comes into possession of a copy. This + License will therefore apply, along with any applicable section 7 + additional terms, to the whole of the work, and all its parts, + regardless of how they are packaged. This License gives no + permission to license the work in any other way, but it does not + invalidate such permission if you have separately received it. + + d) If the work has interactive user interfaces, each must display + Appropriate Legal Notices; however, if the Program has interactive + interfaces that do not display Appropriate Legal Notices, your + work need not make them do so. + + A compilation of a covered work with other separate and independent +works, which are not by their nature extensions of the covered work, +and which are not combined with it such as to form a larger program, +in or on a volume of a storage or distribution medium, is called an +"aggregate" if the compilation and its resulting copyright are not +used to limit the access or legal rights of the compilation's users +beyond what the individual works permit. Inclusion of a covered work +in an aggregate does not cause this License to apply to the other +parts of the aggregate. + + 6. Conveying Non-Source Forms. + + You may convey a covered work in object code form under the terms +of sections 4 and 5, provided that you also convey the +machine-readable Corresponding Source under the terms of this License, +in one of these ways: + + a) Convey the object code in, or embodied in, a physical product + (including a physical distribution medium), accompanied by the + Corresponding Source fixed on a durable physical medium + customarily used for software interchange. + + b) Convey the object code in, or embodied in, a physical product + (including a physical distribution medium), accompanied by a + written offer, valid for at least three years and valid for as + long as you offer spare parts or customer support for that product + model, to give anyone who possesses the object code either (1) a + copy of the Corresponding Source for all the software in the + product that is covered by this License, on a durable physical + medium customarily used for software interchange, for a price no + more than your reasonable cost of physically performing this + conveying of source, or (2) access to copy the + Corresponding Source from a network server at no charge. + + c) Convey individual copies of the object code with a copy of the + written offer to provide the Corresponding Source. This + alternative is allowed only occasionally and noncommercially, and + only if you received the object code with such an offer, in accord + with subsection 6b. + + d) Convey the object code by offering access from a designated + place (gratis or for a charge), and offer equivalent access to the + Corresponding Source in the same way through the same place at no + further charge. You need not require recipients to copy the + Corresponding Source along with the object code. If the place to + copy the object code is a network server, the Corresponding Source + may be on a different server (operated by you or a third party) + that supports equivalent copying facilities, provided you maintain + clear directions next to the object code saying where to find the + Corresponding Source. Regardless of what server hosts the + Corresponding Source, you remain obligated to ensure that it is + available for as long as needed to satisfy these requirements. + + e) Convey the object code using peer-to-peer transmission, provided + you inform other peers where the object code and Corresponding + Source of the work are being offered to the general public at no + charge under subsection 6d. + + A separable portion of the object code, whose source code is excluded +from the Corresponding Source as a System Library, need not be +included in conveying the object code work. + + A "User Product" is either (1) a "consumer product", which means any +tangible personal property which is normally used for personal, family, +or household purposes, or (2) anything designed or sold for incorporation +into a dwelling. In determining whether a product is a consumer product, +doubtful cases shall be resolved in favor of coverage. For a particular +product received by a particular user, "normally used" refers to a +typical or common use of that class of product, regardless of the status +of the particular user or of the way in which the particular user +actually uses, or expects or is expected to use, the product. A product +is a consumer product regardless of whether the product has substantial +commercial, industrial or non-consumer uses, unless such uses represent +the only significant mode of use of the product. + + "Installation Information" for a User Product means any methods, +procedures, authorization keys, or other information required to install +and execute modified versions of a covered work in that User Product from +a modified version of its Corresponding Source. The information must +suffice to ensure that the continued functioning of the modified object +code is in no case prevented or interfered with solely because +modification has been made. + + If you convey an object code work under this section in, or with, or +specifically for use in, a User Product, and the conveying occurs as +part of a transaction in which the right of possession and use of the +User Product is transferred to the recipient in perpetuity or for a +fixed term (regardless of how the transaction is characterized), the +Corresponding Source conveyed under this section must be accompanied +by the Installation Information. But this requirement does not apply +if neither you nor any third party retains the ability to install +modified object code on the User Product (for example, the work has +been installed in ROM). + + The requirement to provide Installation Information does not include a +requirement to continue to provide support service, warranty, or updates +for a work that has been modified or installed by the recipient, or for +the User Product in which it has been modified or installed. Access to a +network may be denied when the modification itself materially and +adversely affects the operation of the network or violates the rules and +protocols for communication across the network. + + Corresponding Source conveyed, and Installation Information provided, +in accord with this section must be in a format that is publicly +documented (and with an implementation available to the public in +source code form), and must require no special password or key for +unpacking, reading or copying. + + 7. Additional Terms. + + "Additional permissions" are terms that supplement the terms of this +License by making exceptions from one or more of its conditions. +Additional permissions that are applicable to the entire Program shall +be treated as though they were included in this License, to the extent +that they are valid under applicable law. If additional permissions +apply only to part of the Program, that part may be used separately +under those permissions, but the entire Program remains governed by +this License without regard to the additional permissions. + + When you convey a copy of a covered work, you may at your option +remove any additional permissions from that copy, or from any part of +it. (Additional permissions may be written to require their own +removal in certain cases when you modify the work.) You may place +additional permissions on material, added by you to a covered work, +for which you have or can give appropriate copyright permission. + + Notwithstanding any other provision of this License, for material you +add to a covered work, you may (if authorized by the copyright holders of +that material) supplement the terms of this License with terms: + + a) Disclaiming warranty or limiting liability differently from the + terms of sections 15 and 16 of this License; or + + b) Requiring preservation of specified reasonable legal notices or + author attributions in that material or in the Appropriate Legal + Notices displayed by works containing it; or + + c) Prohibiting misrepresentation of the origin of that material, or + requiring that modified versions of such material be marked in + reasonable ways as different from the original version; or + + d) Limiting the use for publicity purposes of names of licensors or + authors of the material; or + + e) Declining to grant rights under trademark law for use of some + trade names, trademarks, or service marks; or + + f) Requiring indemnification of licensors and authors of that + material by anyone who conveys the material (or modified versions of + it) with contractual assumptions of liability to the recipient, for + any liability that these contractual assumptions directly impose on + those licensors and authors. + + All other non-permissive additional terms are considered "further +restrictions" within the meaning of section 10. If the Program as you +received it, or any part of it, contains a notice stating that it is +governed by this License along with a term that is a further +restriction, you may remove that term. If a license document contains +a further restriction but permits relicensing or conveying under this +License, you may add to a covered work material governed by the terms +of that license document, provided that the further restriction does +not survive such relicensing or conveying. + + If you add terms to a covered work in accord with this section, you +must place, in the relevant source files, a statement of the +additional terms that apply to those files, or a notice indicating +where to find the applicable terms. + + Additional terms, permissive or non-permissive, may be stated in the +form of a separately written license, or stated as exceptions; +the above requirements apply either way. + + 8. Termination. + + You may not propagate or modify a covered work except as expressly +provided under this License. Any attempt otherwise to propagate or +modify it is void, and will automatically terminate your rights under +this License (including any patent licenses granted under the third +paragraph of section 11). + + However, if you cease all violation of this License, then your +license from a particular copyright holder is reinstated (a) +provisionally, unless and until the copyright holder explicitly and +finally terminates your license, and (b) permanently, if the copyright +holder fails to notify you of the violation by some reasonable means +prior to 60 days after the cessation. + + Moreover, your license from a particular copyright holder is +reinstated permanently if the copyright holder notifies you of the +violation by some reasonable means, this is the first time you have +received notice of violation of this License (for any work) from that +copyright holder, and you cure the violation prior to 30 days after +your receipt of the notice. + + Termination of your rights under this section does not terminate the +licenses of parties who have received copies or rights from you under +this License. If your rights have been terminated and not permanently +reinstated, you do not qualify to receive new licenses for the same +material under section 10. + + 9. Acceptance Not Required for Having Copies. + + You are not required to accept this License in order to receive or +run a copy of the Program. Ancillary propagation of a covered work +occurring solely as a consequence of using peer-to-peer transmission +to receive a copy likewise does not require acceptance. However, +nothing other than this License grants you permission to propagate or +modify any covered work. These actions infringe copyright if you do +not accept this License. Therefore, by modifying or propagating a +covered work, you indicate your acceptance of this License to do so. + + 10. Automatic Licensing of Downstream Recipients. + + Each time you convey a covered work, the recipient automatically +receives a license from the original licensors, to run, modify and +propagate that work, subject to this License. You are not responsible +for enforcing compliance by third parties with this License. + + An "entity transaction" is a transaction transferring control of an +organization, or substantially all assets of one, or subdividing an +organization, or merging organizations. If propagation of a covered +work results from an entity transaction, each party to that +transaction who receives a copy of the work also receives whatever +licenses to the work the party's predecessor in interest had or could +give under the previous paragraph, plus a right to possession of the +Corresponding Source of the work from the predecessor in interest, if +the predecessor has it or can get it with reasonable efforts. + + You may not impose any further restrictions on the exercise of the +rights granted or affirmed under this License. For example, you may +not impose a license fee, royalty, or other charge for exercise of +rights granted under this License, and you may not initiate litigation +(including a cross-claim or counterclaim in a lawsuit) alleging that +any patent claim is infringed by making, using, selling, offering for +sale, or importing the Program or any portion of it. + + 11. Patents. + + A "contributor" is a copyright holder who authorizes use under this +License of the Program or a work on which the Program is based. The +work thus licensed is called the contributor's "contributor version". + + A contributor's "essential patent claims" are all patent claims +owned or controlled by the contributor, whether already acquired or +hereafter acquired, that would be infringed by some manner, permitted +by this License, of making, using, or selling its contributor version, +but do not include claims that would be infringed only as a +consequence of further modification of the contributor version. For +purposes of this definition, "control" includes the right to grant +patent sublicenses in a manner consistent with the requirements of +this License. + + Each contributor grants you a non-exclusive, worldwide, royalty-free +patent license under the contributor's essential patent claims, to +make, use, sell, offer for sale, import and otherwise run, modify and +propagate the contents of its contributor version. + + In the following three paragraphs, a "patent license" is any express +agreement or commitment, however denominated, not to enforce a patent +(such as an express permission to practice a patent or covenant not to +sue for patent infringement). To "grant" such a patent license to a +party means to make such an agreement or commitment not to enforce a +patent against the party. + + If you convey a covered work, knowingly relying on a patent license, +and the Corresponding Source of the work is not available for anyone +to copy, free of charge and under the terms of this License, through a +publicly available network server or other readily accessible means, +then you must either (1) cause the Corresponding Source to be so +available, or (2) arrange to deprive yourself of the benefit of the +patent license for this particular work, or (3) arrange, in a manner +consistent with the requirements of this License, to extend the patent +license to downstream recipients. "Knowingly relying" means you have +actual knowledge that, but for the patent license, your conveying the +covered work in a country, or your recipient's use of the covered work +in a country, would infringe one or more identifiable patents in that +country that you have reason to believe are valid. + + If, pursuant to or in connection with a single transaction or +arrangement, you convey, or propagate by procuring conveyance of, a +covered work, and grant a patent license to some of the parties +receiving the covered work authorizing them to use, propagate, modify +or convey a specific copy of the covered work, then the patent license +you grant is automatically extended to all recipients of the covered +work and works based on it. + + A patent license is "discriminatory" if it does not include within +the scope of its coverage, prohibits the exercise of, or is +conditioned on the non-exercise of one or more of the rights that are +specifically granted under this License. You may not convey a covered +work if you are a party to an arrangement with a third party that is +in the business of distributing software, under which you make payment +to the third party based on the extent of your activity of conveying +the work, and under which the third party grants, to any of the +parties who would receive the covered work from you, a discriminatory +patent license (a) in connection with copies of the covered work +conveyed by you (or copies made from those copies), or (b) primarily +for and in connection with specific products or compilations that +contain the covered work, unless you entered into that arrangement, +or that patent license was granted, prior to 28 March 2007. + + Nothing in this License shall be construed as excluding or limiting +any implied license or other defenses to infringement that may +otherwise be available to you under applicable patent law. + + 12. No Surrender of Others' Freedom. + + If conditions are imposed on you (whether by court order, agreement or +otherwise) that contradict the conditions of this License, they do not +excuse you from the conditions of this License. If you cannot convey a +covered work so as to satisfy simultaneously your obligations under this +License and any other pertinent obligations, then as a consequence you may +not convey it at all. For example, if you agree to terms that obligate you +to collect a royalty for further conveying from those to whom you convey +the Program, the only way you could satisfy both those terms and this +License would be to refrain entirely from conveying the Program. + + 13. Use with the GNU Affero General Public License. + + Notwithstanding any other provision of this License, you have +permission to link or combine any covered work with a work licensed +under version 3 of the GNU Affero General Public License into a single +combined work, and to convey the resulting work. The terms of this +License will continue to apply to the part which is the covered work, +but the special requirements of the GNU Affero General Public License, +section 13, concerning interaction through a network will apply to the +combination as such. + + 14. Revised Versions of this License. + + The Free Software Foundation may publish revised and/or new versions of +the GNU General Public License from time to time. Such new versions will +be similar in spirit to the present version, but may differ in detail to +address new problems or concerns. + + Each version is given a distinguishing version number. If the +Program specifies that a certain numbered version of the GNU General +Public License "or any later version" applies to it, you have the +option of following the terms and conditions either of that numbered +version or of any later version published by the Free Software +Foundation. If the Program does not specify a version number of the +GNU General Public License, you may choose any version ever published +by the Free Software Foundation. + + If the Program specifies that a proxy can decide which future +versions of the GNU General Public License can be used, that proxy's +public statement of acceptance of a version permanently authorizes you +to choose that version for the Program. + + Later license versions may give you additional or different +permissions. However, no additional obligations are imposed on any +author or copyright holder as a result of your choosing to follow a +later version. + + 15. Disclaimer of Warranty. + + THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY +APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT +HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY +OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, +THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM +IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF +ALL NECESSARY SERVICING, REPAIR OR CORRECTION. + + 16. Limitation of Liability. + + IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING +WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS +THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY +GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE +USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF +DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD +PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), +EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF +SUCH DAMAGES. + + 17. Interpretation of Sections 15 and 16. + + If the disclaimer of warranty and limitation of liability provided +above cannot be given local legal effect according to their terms, +reviewing courts shall apply local law that most closely approximates +an absolute waiver of all civil liability in connection with the +Program, unless a warranty or assumption of liability accompanies a +copy of the Program in return for a fee. + + END OF TERMS AND CONDITIONS + + How to Apply These Terms to Your New Programs + + If you develop a new program, and you want it to be of the greatest +possible use to the public, the best way to achieve this is to make it +free software which everyone can redistribute and change under these terms. + + To do so, attach the following notices to the program. It is safest +to attach them to the start of each source file to most effectively +state the exclusion of warranty; and each file should have at least +the "copyright" line and a pointer to where the full notice is found. + + + Copyright (C) + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . + +Also add information on how to contact you by electronic and paper mail. + + If the program does terminal interaction, make it output a short +notice like this when it starts in an interactive mode: + + Copyright (C) + This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'. + This is free software, and you are welcome to redistribute it + under certain conditions; type `show c' for details. + +The hypothetical commands `show w' and `show c' should show the appropriate +parts of the General Public License. Of course, your program's commands +might be different; for a GUI interface, you would use an "about box". + + You should also get your employer (if you work as a programmer) or school, +if any, to sign a "copyright disclaimer" for the program, if necessary. +For more information on this, and how to apply and follow the GNU GPL, see +. + + The GNU General Public License does not permit incorporating your program +into proprietary programs. If your program is a subroutine library, you +may consider it more useful to permit linking proprietary applications with +the library. If this is what you want to do, use the GNU Lesser General +Public License instead of this License. But first, please read +. GNU GENERAL PUBLIC LICENSE + Version 3, 29 June 2007 + + Copyright (C) 2007 Free Software Foundation, Inc. + Everyone is permitted to copy and distribute verbatim copies + of this license document, but changing it is not allowed. + + Preamble + + The GNU General Public License is a free, copyleft license for +software and other kinds of works. + + The licenses for most software and other practical works are designed +to take away your freedom to share and change the works. By contrast, +the GNU General Public License is intended to guarantee your freedom to +share and change all versions of a program--to make sure it remains free +software for all its users. We, the Free Software Foundation, use the +GNU General Public License for most of our software; it applies also to +any other work released this way by its authors. You can apply it to +your programs, too. + + When we speak of free software, we are referring to freedom, not +price. Our General Public Licenses are designed to make sure that you +have the freedom to distribute copies of free software (and charge for +them if you wish), that you receive source code or can get it if you +want it, that you can change the software or use pieces of it in new +free programs, and that you know you can do these things. + + To protect your rights, we need to prevent others from denying you +these rights or asking you to surrender the rights. Therefore, you have +certain responsibilities if you distribute copies of the software, or if +you modify it: responsibilities to respect the freedom of others. + + For example, if you distribute copies of such a program, whether +gratis or for a fee, you must pass on to the recipients the same +freedoms that you received. You must make sure that they, too, receive +or can get the source code. And you must show them these terms so they +know their rights. + + Developers that use the GNU GPL protect your rights with two steps: +(1) assert copyright on the software, and (2) offer you this License +giving you legal permission to copy, distribute and/or modify it. + + For the developers' and authors' protection, the GPL clearly explains +that there is no warranty for this free software. For both users' and +authors' sake, the GPL requires that modified versions be marked as +changed, so that their problems will not be attributed erroneously to +authors of previous versions. + + Some devices are designed to deny users access to install or run +modified versions of the software inside them, although the manufacturer +can do so. This is fundamentally incompatible with the aim of +protecting users' freedom to change the software. The systematic +pattern of such abuse occurs in the area of products for individuals to +use, which is precisely where it is most unacceptable. Therefore, we +have designed this version of the GPL to prohibit the practice for those +products. If such problems arise substantially in other domains, we +stand ready to extend this provision to those domains in future versions +of the GPL, as needed to protect the freedom of users. + + Finally, every program is threatened constantly by software patents. +States should not allow patents to restrict development and use of +software on general-purpose computers, but in those that do, we wish to +avoid the special danger that patents applied to a free program could +make it effectively proprietary. To prevent this, the GPL assures that +patents cannot be used to render the program non-free. + + The precise terms and conditions for copying, distribution and +modification follow. + + TERMS AND CONDITIONS + + 0. Definitions. + + "This License" refers to version 3 of the GNU General Public License. + + "Copyright" also means copyright-like laws that apply to other kinds of +works, such as semiconductor masks. + + "The Program" refers to any copyrightable work licensed under this +License. Each licensee is addressed as "you". "Licensees" and +"recipients" may be individuals or organizations. + + To "modify" a work means to copy from or adapt all or part of the work +in a fashion requiring copyright permission, other than the making of an +exact copy. The resulting work is called a "modified version" of the +earlier work or a work "based on" the earlier work. + + A "covered work" means either the unmodified Program or a work based +on the Program. + + To "propagate" a work means to do anything with it that, without +permission, would make you directly or secondarily liable for +infringement under applicable copyright law, except executing it on a +computer or modifying a private copy. Propagation includes copying, +distribution (with or without modification), making available to the +public, and in some countries other activities as well. + + To "convey" a work means any kind of propagation that enables other +parties to make or receive copies. Mere interaction with a user through +a computer network, with no transfer of a copy, is not conveying. + + An interactive user interface displays "Appropriate Legal Notices" +to the extent that it includes a convenient and prominently visible +feature that (1) displays an appropriate copyright notice, and (2) +tells the user that there is no warranty for the work (except to the +extent that warranties are provided), that licensees may convey the +work under this License, and how to view a copy of this License. If +the interface presents a list of user commands or options, such as a +menu, a prominent item in the list meets this criterion. + + 1. Source Code. + + The "source code" for a work means the preferred form of the work +for making modifications to it. "Object code" means any non-source +form of a work. + + A "Standard Interface" means an interface that either is an official +standard defined by a recognized standards body, or, in the case of +interfaces specified for a particular programming language, one that +is widely used among developers working in that language. + + The "System Libraries" of an executable work include anything, other +than the work as a whole, that (a) is included in the normal form of +packaging a Major Component, but which is not part of that Major +Component, and (b) serves only to enable use of the work with that +Major Component, or to implement a Standard Interface for which an +implementation is available to the public in source code form. A +"Major Component", in this context, means a major essential component +(kernel, window system, and so on) of the specific operating system +(if any) on which the executable work runs, or a compiler used to +produce the work, or an object code interpreter used to run it. + + The "Corresponding Source" for a work in object code form means all +the source code needed to generate, install, and (for an executable +work) run the object code and to modify the work, including scripts to +control those activities. However, it does not include the work's +System Libraries, or general-purpose tools or generally available free +programs which are used unmodified in performing those activities but +which are not part of the work. For example, Corresponding Source +includes interface definition files associated with source files for +the work, and the source code for shared libraries and dynamically +linked subprograms that the work is specifically designed to require, +such as by intimate data communication or control flow between those +subprograms and other parts of the work. + + The Corresponding Source need not include anything that users +can regenerate automatically from other parts of the Corresponding +Source. + + The Corresponding Source for a work in source code form is that +same work. + + 2. Basic Permissions. + + All rights granted under this License are granted for the term of +copyright on the Program, and are irrevocable provided the stated +conditions are met. This License explicitly affirms your unlimited +permission to run the unmodified Program. The output from running a +covered work is covered by this License only if the output, given its +content, constitutes a covered work. This License acknowledges your +rights of fair use or other equivalent, as provided by copyright law. + + You may make, run and propagate covered works that you do not +convey, without conditions so long as your license otherwise remains +in force. You may convey covered works to others for the sole purpose +of having them make modifications exclusively for you, or provide you +with facilities for running those works, provided that you comply with +the terms of this License in conveying all material for which you do +not control copyright. Those thus making or running the covered works +for you must do so exclusively on your behalf, under your direction +and control, on terms that prohibit them from making any copies of +your copyrighted material outside their relationship with you. + + Conveying under any other circumstances is permitted solely under +the conditions stated below. Sublicensing is not allowed; section 10 +makes it unnecessary. + + 3. Protecting Users' Legal Rights From Anti-Circumvention Law. + + No covered work shall be deemed part of an effective technological +measure under any applicable law fulfilling obligations under article +11 of the WIPO copyright treaty adopted on 20 December 1996, or +similar laws prohibiting or restricting circumvention of such +measures. + + When you convey a covered work, you waive any legal power to forbid +circumvention of technological measures to the extent such circumvention +is effected by exercising rights under this License with respect to +the covered work, and you disclaim any intention to limit operation or +modification of the work as a means of enforcing, against the work's +users, your or third parties' legal rights to forbid circumvention of +technological measures. + + 4. Conveying Verbatim Copies. + + You may convey verbatim copies of the Program's source code as you +receive it, in any medium, provided that you conspicuously and +appropriately publish on each copy an appropriate copyright notice; +keep intact all notices stating that this License and any +non-permissive terms added in accord with section 7 apply to the code; +keep intact all notices of the absence of any warranty; and give all +recipients a copy of this License along with the Program. + + You may charge any price or no price for each copy that you convey, +and you may offer support or warranty protection for a fee. + + 5. Conveying Modified Source Versions. + + You may convey a work based on the Program, or the modifications to +produce it from the Program, in the form of source code under the +terms of section 4, provided that you also meet all of these conditions: + + a) The work must carry prominent notices stating that you modified + it, and giving a relevant date. + + b) The work must carry prominent notices stating that it is + released under this License and any conditions added under section + 7. This requirement modifies the requirement in section 4 to + "keep intact all notices". + + c) You must license the entire work, as a whole, under this + License to anyone who comes into possession of a copy. This + License will therefore apply, along with any applicable section 7 + additional terms, to the whole of the work, and all its parts, + regardless of how they are packaged. This License gives no + permission to license the work in any other way, but it does not + invalidate such permission if you have separately received it. + + d) If the work has interactive user interfaces, each must display + Appropriate Legal Notices; however, if the Program has interactive + interfaces that do not display Appropriate Legal Notices, your + work need not make them do so. + + A compilation of a covered work with other separate and independent +works, which are not by their nature extensions of the covered work, +and which are not combined with it such as to form a larger program, +in or on a volume of a storage or distribution medium, is called an +"aggregate" if the compilation and its resulting copyright are not +used to limit the access or legal rights of the compilation's users +beyond what the individual works permit. Inclusion of a covered work +in an aggregate does not cause this License to apply to the other +parts of the aggregate. + + 6. Conveying Non-Source Forms. + + You may convey a covered work in object code form under the terms +of sections 4 and 5, provided that you also convey the +machine-readable Corresponding Source under the terms of this License, +in one of these ways: + + a) Convey the object code in, or embodied in, a physical product + (including a physical distribution medium), accompanied by the + Corresponding Source fixed on a durable physical medium + customarily used for software interchange. + + b) Convey the object code in, or embodied in, a physical product + (including a physical distribution medium), accompanied by a + written offer, valid for at least three years and valid for as + long as you offer spare parts or customer support for that product + model, to give anyone who possesses the object code either (1) a + copy of the Corresponding Source for all the software in the + product that is covered by this License, on a durable physical + medium customarily used for software interchange, for a price no + more than your reasonable cost of physically performing this + conveying of source, or (2) access to copy the + Corresponding Source from a network server at no charge. + + c) Convey individual copies of the object code with a copy of the + written offer to provide the Corresponding Source. This + alternative is allowed only occasionally and noncommercially, and + only if you received the object code with such an offer, in accord + with subsection 6b. + + d) Convey the object code by offering access from a designated + place (gratis or for a charge), and offer equivalent access to the + Corresponding Source in the same way through the same place at no + further charge. You need not require recipients to copy the + Corresponding Source along with the object code. If the place to + copy the object code is a network server, the Corresponding Source + may be on a different server (operated by you or a third party) + that supports equivalent copying facilities, provided you maintain + clear directions next to the object code saying where to find the + Corresponding Source. Regardless of what server hosts the + Corresponding Source, you remain obligated to ensure that it is + available for as long as needed to satisfy these requirements. + + e) Convey the object code using peer-to-peer transmission, provided + you inform other peers where the object code and Corresponding + Source of the work are being offered to the general public at no + charge under subsection 6d. + + A separable portion of the object code, whose source code is excluded +from the Corresponding Source as a System Library, need not be +included in conveying the object code work. + + A "User Product" is either (1) a "consumer product", which means any +tangible personal property which is normally used for personal, family, +or household purposes, or (2) anything designed or sold for incorporation +into a dwelling. In determining whether a product is a consumer product, +doubtful cases shall be resolved in favor of coverage. For a particular +product received by a particular user, "normally used" refers to a +typical or common use of that class of product, regardless of the status +of the particular user or of the way in which the particular user +actually uses, or expects or is expected to use, the product. A product +is a consumer product regardless of whether the product has substantial +commercial, industrial or non-consumer uses, unless such uses represent +the only significant mode of use of the product. + + "Installation Information" for a User Product means any methods, +procedures, authorization keys, or other information required to install +and execute modified versions of a covered work in that User Product from +a modified version of its Corresponding Source. The information must +suffice to ensure that the continued functioning of the modified object +code is in no case prevented or interfered with solely because +modification has been made. + + If you convey an object code work under this section in, or with, or +specifically for use in, a User Product, and the conveying occurs as +part of a transaction in which the right of possession and use of the +User Product is transferred to the recipient in perpetuity or for a +fixed term (regardless of how the transaction is characterized), the +Corresponding Source conveyed under this section must be accompanied +by the Installation Information. But this requirement does not apply +if neither you nor any third party retains the ability to install +modified object code on the User Product (for example, the work has +been installed in ROM). + + The requirement to provide Installation Information does not include a +requirement to continue to provide support service, warranty, or updates +for a work that has been modified or installed by the recipient, or for +the User Product in which it has been modified or installed. Access to a +network may be denied when the modification itself materially and +adversely affects the operation of the network or violates the rules and +protocols for communication across the network. + + Corresponding Source conveyed, and Installation Information provided, +in accord with this section must be in a format that is publicly +documented (and with an implementation available to the public in +source code form), and must require no special password or key for +unpacking, reading or copying. + + 7. Additional Terms. + + "Additional permissions" are terms that supplement the terms of this +License by making exceptions from one or more of its conditions. +Additional permissions that are applicable to the entire Program shall +be treated as though they were included in this License, to the extent +that they are valid under applicable law. If additional permissions +apply only to part of the Program, that part may be used separately +under those permissions, but the entire Program remains governed by +this License without regard to the additional permissions. + + When you convey a copy of a covered work, you may at your option +remove any additional permissions from that copy, or from any part of +it. (Additional permissions may be written to require their own +removal in certain cases when you modify the work.) You may place +additional permissions on material, added by you to a covered work, +for which you have or can give appropriate copyright permission. + + Notwithstanding any other provision of this License, for material you +add to a covered work, you may (if authorized by the copyright holders of +that material) supplement the terms of this License with terms: + + a) Disclaiming warranty or limiting liability differently from the + terms of sections 15 and 16 of this License; or + + b) Requiring preservation of specified reasonable legal notices or + author attributions in that material or in the Appropriate Legal + Notices displayed by works containing it; or + + c) Prohibiting misrepresentation of the origin of that material, or + requiring that modified versions of such material be marked in + reasonable ways as different from the original version; or + + d) Limiting the use for publicity purposes of names of licensors or + authors of the material; or + + e) Declining to grant rights under trademark law for use of some + trade names, trademarks, or service marks; or + + f) Requiring indemnification of licensors and authors of that + material by anyone who conveys the material (or modified versions of + it) with contractual assumptions of liability to the recipient, for + any liability that these contractual assumptions directly impose on + those licensors and authors. + + All other non-permissive additional terms are considered "further +restrictions" within the meaning of section 10. If the Program as you +received it, or any part of it, contains a notice stating that it is +governed by this License along with a term that is a further +restriction, you may remove that term. If a license document contains +a further restriction but permits relicensing or conveying under this +License, you may add to a covered work material governed by the terms +of that license document, provided that the further restriction does +not survive such relicensing or conveying. + + If you add terms to a covered work in accord with this section, you +must place, in the relevant source files, a statement of the +additional terms that apply to those files, or a notice indicating +where to find the applicable terms. + + Additional terms, permissive or non-permissive, may be stated in the +form of a separately written license, or stated as exceptions; +the above requirements apply either way. + + 8. Termination. + + You may not propagate or modify a covered work except as expressly +provided under this License. Any attempt otherwise to propagate or +modify it is void, and will automatically terminate your rights under +this License (including any patent licenses granted under the third +paragraph of section 11). + + However, if you cease all violation of this License, then your +license from a particular copyright holder is reinstated (a) +provisionally, unless and until the copyright holder explicitly and +finally terminates your license, and (b) permanently, if the copyright +holder fails to notify you of the violation by some reasonable means +prior to 60 days after the cessation. + + Moreover, your license from a particular copyright holder is +reinstated permanently if the copyright holder notifies you of the +violation by some reasonable means, this is the first time you have +received notice of violation of this License (for any work) from that +copyright holder, and you cure the violation prior to 30 days after +your receipt of the notice. + + Termination of your rights under this section does not terminate the +licenses of parties who have received copies or rights from you under +this License. If your rights have been terminated and not permanently +reinstated, you do not qualify to receive new licenses for the same +material under section 10. + + 9. Acceptance Not Required for Having Copies. + + You are not required to accept this License in order to receive or +run a copy of the Program. Ancillary propagation of a covered work +occurring solely as a consequence of using peer-to-peer transmission +to receive a copy likewise does not require acceptance. However, +nothing other than this License grants you permission to propagate or +modify any covered work. These actions infringe copyright if you do +not accept this License. Therefore, by modifying or propagating a +covered work, you indicate your acceptance of this License to do so. + + 10. Automatic Licensing of Downstream Recipients. + + Each time you convey a covered work, the recipient automatically +receives a license from the original licensors, to run, modify and +propagate that work, subject to this License. You are not responsible +for enforcing compliance by third parties with this License. + + An "entity transaction" is a transaction transferring control of an +organization, or substantially all assets of one, or subdividing an +organization, or merging organizations. If propagation of a covered +work results from an entity transaction, each party to that +transaction who receives a copy of the work also receives whatever +licenses to the work the party's predecessor in interest had or could +give under the previous paragraph, plus a right to possession of the +Corresponding Source of the work from the predecessor in interest, if +the predecessor has it or can get it with reasonable efforts. + + You may not impose any further restrictions on the exercise of the +rights granted or affirmed under this License. For example, you may +not impose a license fee, royalty, or other charge for exercise of +rights granted under this License, and you may not initiate litigation +(including a cross-claim or counterclaim in a lawsuit) alleging that +any patent claim is infringed by making, using, selling, offering for +sale, or importing the Program or any portion of it. + + 11. Patents. + + A "contributor" is a copyright holder who authorizes use under this +License of the Program or a work on which the Program is based. The +work thus licensed is called the contributor's "contributor version". + + A contributor's "essential patent claims" are all patent claims +owned or controlled by the contributor, whether already acquired or +hereafter acquired, that would be infringed by some manner, permitted +by this License, of making, using, or selling its contributor version, +but do not include claims that would be infringed only as a +consequence of further modification of the contributor version. For +purposes of this definition, "control" includes the right to grant +patent sublicenses in a manner consistent with the requirements of +this License. + + Each contributor grants you a non-exclusive, worldwide, royalty-free +patent license under the contributor's essential patent claims, to +make, use, sell, offer for sale, import and otherwise run, modify and +propagate the contents of its contributor version. + + In the following three paragraphs, a "patent license" is any express +agreement or commitment, however denominated, not to enforce a patent +(such as an express permission to practice a patent or covenant not to +sue for patent infringement). To "grant" such a patent license to a +party means to make such an agreement or commitment not to enforce a +patent against the party. + + If you convey a covered work, knowingly relying on a patent license, +and the Corresponding Source of the work is not available for anyone +to copy, free of charge and under the terms of this License, through a +publicly available network server or other readily accessible means, +then you must either (1) cause the Corresponding Source to be so +available, or (2) arrange to deprive yourself of the benefit of the +patent license for this particular work, or (3) arrange, in a manner +consistent with the requirements of this License, to extend the patent +license to downstream recipients. "Knowingly relying" means you have +actual knowledge that, but for the patent license, your conveying the +covered work in a country, or your recipient's use of the covered work +in a country, would infringe one or more identifiable patents in that +country that you have reason to believe are valid. + + If, pursuant to or in connection with a single transaction or +arrangement, you convey, or propagate by procuring conveyance of, a +covered work, and grant a patent license to some of the parties +receiving the covered work authorizing them to use, propagate, modify +or convey a specific copy of the covered work, then the patent license +you grant is automatically extended to all recipients of the covered +work and works based on it. + + A patent license is "discriminatory" if it does not include within +the scope of its coverage, prohibits the exercise of, or is +conditioned on the non-exercise of one or more of the rights that are +specifically granted under this License. You may not convey a covered +work if you are a party to an arrangement with a third party that is +in the business of distributing software, under which you make payment +to the third party based on the extent of your activity of conveying +the work, and under which the third party grants, to any of the +parties who would receive the covered work from you, a discriminatory +patent license (a) in connection with copies of the covered work +conveyed by you (or copies made from those copies), or (b) primarily +for and in connection with specific products or compilations that +contain the covered work, unless you entered into that arrangement, +or that patent license was granted, prior to 28 March 2007. + + Nothing in this License shall be construed as excluding or limiting +any implied license or other defenses to infringement that may +otherwise be available to you under applicable patent law. + + 12. No Surrender of Others' Freedom. + + If conditions are imposed on you (whether by court order, agreement or +otherwise) that contradict the conditions of this License, they do not +excuse you from the conditions of this License. If you cannot convey a +covered work so as to satisfy simultaneously your obligations under this +License and any other pertinent obligations, then as a consequence you may +not convey it at all. For example, if you agree to terms that obligate you +to collect a royalty for further conveying from those to whom you convey +the Program, the only way you could satisfy both those terms and this +License would be to refrain entirely from conveying the Program. + + 13. Use with the GNU Affero General Public License. + + Notwithstanding any other provision of this License, you have +permission to link or combine any covered work with a work licensed +under version 3 of the GNU Affero General Public License into a single +combined work, and to convey the resulting work. The terms of this +License will continue to apply to the part which is the covered work, +but the special requirements of the GNU Affero General Public License, +section 13, concerning interaction through a network will apply to the +combination as such. + + 14. Revised Versions of this License. + + The Free Software Foundation may publish revised and/or new versions of +the GNU General Public License from time to time. Such new versions will +be similar in spirit to the present version, but may differ in detail to +address new problems or concerns. + + Each version is given a distinguishing version number. If the +Program specifies that a certain numbered version of the GNU General +Public License "or any later version" applies to it, you have the +option of following the terms and conditions either of that numbered +version or of any later version published by the Free Software +Foundation. If the Program does not specify a version number of the +GNU General Public License, you may choose any version ever published +by the Free Software Foundation. + + If the Program specifies that a proxy can decide which future +versions of the GNU General Public License can be used, that proxy's +public statement of acceptance of a version permanently authorizes you +to choose that version for the Program. + + Later license versions may give you additional or different +permissions. However, no additional obligations are imposed on any +author or copyright holder as a result of your choosing to follow a +later version. + + 15. Disclaimer of Warranty. + + THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY +APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT +HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY +OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, +THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM +IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF +ALL NECESSARY SERVICING, REPAIR OR CORRECTION. + + 16. Limitation of Liability. + + IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING +WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS +THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY +GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE +USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF +DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD +PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), +EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF +SUCH DAMAGES. + + 17. Interpretation of Sections 15 and 16. + + If the disclaimer of warranty and limitation of liability provided +above cannot be given local legal effect according to their terms, +reviewing courts shall apply local law that most closely approximates +an absolute waiver of all civil liability in connection with the +Program, unless a warranty or assumption of liability accompanies a +copy of the Program in return for a fee. + + END OF TERMS AND CONDITIONS + + How to Apply These Terms to Your New Programs + + If you develop a new program, and you want it to be of the greatest +possible use to the public, the best way to achieve this is to make it +free software which everyone can redistribute and change under these terms. + + To do so, attach the following notices to the program. It is safest +to attach them to the start of each source file to most effectively +state the exclusion of warranty; and each file should have at least +the "copyright" line and a pointer to where the full notice is found. + + + Copyright (C) + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . + +Also add information on how to contact you by electronic and paper mail. + + If the program does terminal interaction, make it output a short +notice like this when it starts in an interactive mode: + + Copyright (C) + This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'. + This is free software, and you are welcome to redistribute it + under certain conditions; type `show c' for details. + +The hypothetical commands `show w' and `show c' should show the appropriate +parts of the General Public License. Of course, your program's commands +might be different; for a GUI interface, you would use an "about box". + + You should also get your employer (if you work as a programmer) or school, +if any, to sign a "copyright disclaimer" for the program, if necessary. +For more information on this, and how to apply and follow the GNU GPL, see +. + + The GNU General Public License does not permit incorporating your program +into proprietary programs. If your program is a subroutine library, you +may consider it more useful to permit linking proprietary applications with +the library. If this is what you want to do, use the GNU Lesser General +Public License instead of this License. But first, please read +. diff --git a/gulagcleaner_python/README.md b/gulagcleaner_python/README.md new file mode 100644 index 0000000..51fd410 --- /dev/null +++ b/gulagcleaner_python/README.md @@ -0,0 +1,71 @@ + +# Gulag Cleaner + + +[![Twitter](https://a11ybadges.com/badge?logo=twitter)](https://twitter.com/gulagcleaner) +[![Instagram](https://a11ybadges.com/badge?logo=instagram)](https://www.instagram.com/gulagcleaner/) +[![Ko-fi](https://a11ybadges.com/badge?logo=kofi)](https://ko-fi.com/L3L86VEX9) + + +Gulag Cleaner is a tool designed to remove advertisements from PDFs, making it easier to read and navigate documents without being disrupted by unwanted ads. + +This tool does not just crop the ads out of the PDF, instead, we extract the original file without ads by manipulating the internal structure of the PDF, ensuring maximum quality. + +In addition to removing advertisements, Gulag Cleaner is also capable of extracting metadata, such as the author, subject, university, and more, from the file. + +# Web Version + +This tool can be used without installation directly from [our website](https://gulagcleaner.com) (in Spanish). + +[![Gulag Cleaner webpage](https://raw.githubusercontent.com/YM162/gulagcleaner/main/assets/web_mockup.png)](https://gulagcleaner.com) + +# Installation + +To install Gulag Cleaner, please [download](https://www.python.org/downloads/) and [install](https://wiki.python.org/moin/BeginnersGuide/Download) Python and then run the following command in your terminal: +``` +pip install gulagcleaner +``` + +# Usage + +Gulag Cleaner can be used through both a Command Line Interface (CLI) and in your code. + +## Command Line Interface + +To use Gulag Cleaner through the CLI, simply run the following command, replacing `` with the name of one or more PDF files or folders containing PDF: + +``` +gulagcleaner [-r] [-s] [-h] [-v] ... +``` + +## Options + +Gulag Cleaner provides several options for its usage: + +> * '-r': Replace the original file with the cleaned version. +> * '-s': Do not show metadata about cleaned files. +> * '-h': Display the help message, providing information on how to use Gulag Cleaner. +> * '-v': Display the current version of Gulag Cleaner. + +## Code + +To use Gulag Cleaner in your code, you can use the following code snippet: + +```python +from gulagcleaner.extract import clean_pdf + +return_msg = clean_pdf("file.pdf") +``` + +# License +Gulag Cleaner is distributed under the GPL-3 license, which means it's open-source and free to use. + +# Contributing +We're always looking for ways to improve Gulag Cleaner, and we welcome contributions from the community. If you have ideas for improvements or bug fixes, please feel free to submit a pull request. + +## TODO +If you want to help, these are the top priorities right now: + +* Revamp the argument parsing. We should use some parsing library to allow for short "-v" and long "--version" arguments. Idealy it should support parameters for each argument. + +* Add the "Naive" cleaning method. This method is just a fallback that crops the Ads by zooming in and moving the MediaBox. This is not ideal, but there will always be edge cases not covered in the other methods and doing this better than giving an error. \ No newline at end of file diff --git a/gulagcleaner_python/pyproject.toml b/gulagcleaner_python/pyproject.toml index 47ca0b1..f63dda3 100644 --- a/gulagcleaner_python/pyproject.toml +++ b/gulagcleaner_python/pyproject.toml @@ -8,11 +8,11 @@ version = "0.0.1" description = "Ad removal tool for PDFs." authors = [ {name = "YM162", email = "david.fontaneda16@gmail.com"}] -readme = "../README.md" +readme = "README.md" dependencies = [ "pikepdf>=5.1.2","pdfminer.six>=20220524" ] -license = {file = "../LICENSE"} +license = {file = "LICENSE"} classifiers = ["Programming Language :: Python :: 3", "License :: OSI Approved :: MIT License", "Operating System :: OS Independent"] diff --git a/gulagcleaner_python/python/gulagcleaner/__pycache__/clean.cpython-38.pyc b/gulagcleaner_python/python/gulagcleaner/__pycache__/clean.cpython-38.pyc index 5fa64865f73ca93ec9f0bf75433f4f2e9316efbd..ce8532a4aabd5b7652dea9258e3f25be167d5156 100644 GIT binary patch literal 1383 zcmaJ>O=}b}7*6J6KU?WRu=P-K>>lh*C`H6lEecY!AG9tD%j_hx9XdNRB$;lv?0Tts z5_%U8RzdK8c=9LYCZ75i1i?3%*>)<_EXn5mdfxYalF9DuYy-jg`Scz8>LT<@3*}*f z@Cc@uhlL`FBQ(Hmj1je{{RXuy>TIKydx62+!m92^%!|7z4SX9k(@}$s&a)0v{D9@; zy+mU`JGIV^C-&I>gwN5$k=EE5Tc_5<1uLeoJ6i#(D`B2uYR{tuG^vbT>Rf5wTA*_Q z!I7@^I)~c!(0%k0ZJ~Wc-7y|lXoXfkI(x_}^k2YZyYSdU@rr|F<*>oOV>GE^baI#0 zAfh6x<0@o@$O`zsLZ7W|MC+64>*_v8u?6UL=)K{60FoL6#=34^5P86eM+FIZGBCo6 z#~UOFBSylQc%&a5v6!TuJRn|7iSUk?AfYtIIDuepjLQacjrYZ>+35tpYu5xW3CUZl zWCt=CStceC*iE85R!1b6Ofz|7kWOwQ&ABnEGyH=PB;04+*n_IcQZGp&$h&vIOr4O{ zm<>ekVt~T9PX^$U(7ci@CNmzF8sSFK9f&?zqMokgTV|*8m`_5#QDPAmbj!js zxP}|B&f(j59$WeE&!RJj`2u)sw(Pdkjl!NG!Kh4yrA5Dys`g-z&@5sPHQz!LHe>w- DTx5$^ delta 182 zcmaFP^@@ovl$V!_0SGQJx28T~n#gDGyOQx1Z*ggEd}48YaY<2TUV1V!NC6ap*dXi- z#Kj<;B@8KyDNM~w!3>(relI~HFWG=Z5fhNmWS$(!qQbJ0p@?(xJeD9k&g7ib#Ju=| slr&zTY%xd)17i_4ko41Jj$(<=$xJE&84eaI;smh}1lMGLR&hoi0Kvi{e*gdg diff --git a/gulagcleaner_python/python/gulagcleaner/__pycache__/command_line.cpython-38.pyc b/gulagcleaner_python/python/gulagcleaner/__pycache__/command_line.cpython-38.pyc index 0d40d6450f838f31991359c991132a15d4353827..d7ebec639d1a1cdaf9dbaf6a7c944f5e6d1d01e5 100644 GIT binary patch delta 54 zcmZ1=vs8vRl$V!_0SG2|w54)SlpK0D{l%Z5z1{GjiTyE=WmR$xy^T`8s2fB_~iulc|UqNELzDMeL{q Z2atPlpK00IM+){WeU89Aev3sTZnG8C~*zRp-=$pMtnWGZ3?Qbizk5gRJO Z4&>hAu*uC&Da}c>V+8VwnScZb696bC5C{MO diff --git a/gulagcleaner_python/python/gulagcleaner/clean.py b/gulagcleaner_python/python/gulagcleaner/clean.py index 19f70a2..5c3967f 100644 --- a/gulagcleaner_python/python/gulagcleaner/clean.py +++ b/gulagcleaner_python/python/gulagcleaner/clean.py @@ -1,14 +1,30 @@ from ._lib import clean_pdf # export public parts of the binary extension -#Here there should only be a function clean_pdf(pdf_path, output_path, force_naive) -#that calls the rust function and then saves the pdf in the given output_path. -#It should return a dictionary with the following keys: -# Returns: -# return_msg (dict): A dictionary with the following keys: -# success (bool): Indicates whether the de-embedding process was successful. -# return_path (str): The path to the de-embedded file if successful. -# error (str): An error description if the process was unsuccessful. -# """ - -def clean_pdf(pdf_path, output_path, force_naive): - return clean_pdf(10,6) \ No newline at end of file +def clean_pdf_path(pdf_path, output_path, force_naive): + """ + Cleans the ads from the PDF file in a given path and saves it in another path. + Args: + pdf_path (str): The path to the pdf file. + output_path (str): The path to save the cleaned pdf file. + force_naive (bool): Whether to force the naive cleaning method. + Returns: + return_msg (dict): A dictionary with the following keys: + success (bool): Indicates whether the de-embedding process was successful. + return_path (str): The path to the cleaned file if successful. + method (str): The method used to clean the file. + error (str): An error description if the process was unsuccessful. + """ + try: + with open(pdf_path, "rb") as f: + pdf = f.read() + cleaned_pdf = clean_pdf(pdf, force_naive) + with open(output_path, "wb") as f: + method = cleaned_pdf[len(cleaned_pdf)-1] + cleaned_pdf = cleaned_pdf[0:len(cleaned_pdf)-1] + f.write(bytes(cleaned_pdf)) + return {"success": True, + "return_path": output_path, + "method": method, + "error": ""} + except Exception as e: + return {"success": False, "return_path": "","method":"", "error": str(e)} \ No newline at end of file diff --git a/gulagcleaner_python/python/gulagcleaner/command_line.py b/gulagcleaner_python/python/gulagcleaner/command_line.py index 88a8aac..15acfc1 100644 --- a/gulagcleaner_python/python/gulagcleaner/command_line.py +++ b/gulagcleaner_python/python/gulagcleaner/command_line.py @@ -1,4 +1,4 @@ -from gulagcleaner.clean import clean_pdf +from gulagcleaner.clean import clean_pdf_path from gulagcleaner.decrypt import decrypt_pdf from gulagcleaner.metadata import extract_metadata from os.path import exists, isdir, join @@ -109,13 +109,13 @@ def main(): print("Failed to extract metadata:", e) # Call the cleaning function - return_msg = clean_pdf(pdf_path, output_path, force_naive) + return_msg = clean_pdf_path(pdf_path, output_path, force_naive) remove(pdf_path) - if return_msg["Success"]: + if return_msg["success"]: print("Cleaning successful. File saved in " + return_msg["return_path"]) else: - print("Error cleaning " + pdf_path + ": " + return_msg["Error"]) + print("Error cleaning " + pdf_path + ": " + return_msg["error"]) if __name__ == "__main__": print('Call from the "gulagcleaner" command.') diff --git a/gulagcleaner_python/rust/lib.rs b/gulagcleaner_python/rust/lib.rs index a70dc8a..73d367f 100644 --- a/gulagcleaner_python/rust/lib.rs +++ b/gulagcleaner_python/rust/lib.rs @@ -1,10 +1,9 @@ use pyo3::prelude::*; -use gulagcleaner; /// I only need to replace the sum_as_string function with the clean_pdf function, and the arguments to be u8 vectors. Maybe I need to change some types here to pure rust. #[pyfunction] -pub fn clean_pdf(a: usize, b: usize) -> PyResult { - Ok(gulagcleaner::clean_pdf(a, b)) +pub fn clean_pdf(data: Vec,force_naive: u8) -> PyResult> { + Ok(gulagcleaner_rs::clean_pdf(data, force_naive)) } /// I only need to replace the sum_as_string function with the clean_pdf function diff --git a/gulagcleaner/Cargo.toml b/gulagcleaner_rs/Cargo.toml similarity index 89% rename from gulagcleaner/Cargo.toml rename to gulagcleaner_rs/Cargo.toml index 77a2388..d2c318f 100644 --- a/gulagcleaner/Cargo.toml +++ b/gulagcleaner_rs/Cargo.toml @@ -1,5 +1,5 @@ [package] -name = "gulagcleaner" +name = "gulagcleaner_rs" version = "0.10.0" edition = "2021" authors = ["YM162 "] @@ -13,8 +13,7 @@ keywords = ["wuolah", "pdf", "ads", "advertisments", "cleaner", "gulagcleaner"] # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html [lib] -name = "gulagcleaner" -crate-type = ["lib"] +name = "gulagcleaner_rs" [dependencies] flate2 = "1.0.27" diff --git a/gulagcleaner_rs/LICENSE b/gulagcleaner_rs/LICENSE new file mode 100644 index 0000000..ca40b21 --- /dev/null +++ b/gulagcleaner_rs/LICENSE @@ -0,0 +1,1347 @@ + GNU GENERAL PUBLIC LICENSE + Version 3, 29 June 2007 + + Copyright (C) 2007 Free Software Foundation, Inc. + Everyone is permitted to copy and distribute verbatim copies + of this license document, but changing it is not allowed. + + Preamble + + The GNU General Public License is a free, copyleft license for +software and other kinds of works. + + The licenses for most software and other practical works are designed +to take away your freedom to share and change the works. By contrast, +the GNU General Public License is intended to guarantee your freedom to +share and change all versions of a program--to make sure it remains free +software for all its users. We, the Free Software Foundation, use the +GNU General Public License for most of our software; it applies also to +any other work released this way by its authors. You can apply it to +your programs, too. + + When we speak of free software, we are referring to freedom, not +price. Our General Public Licenses are designed to make sure that you +have the freedom to distribute copies of free software (and charge for +them if you wish), that you receive source code or can get it if you +want it, that you can change the software or use pieces of it in new +free programs, and that you know you can do these things. + + To protect your rights, we need to prevent others from denying you +these rights or asking you to surrender the rights. Therefore, you have +certain responsibilities if you distribute copies of the software, or if +you modify it: responsibilities to respect the freedom of others. + + For example, if you distribute copies of such a program, whether +gratis or for a fee, you must pass on to the recipients the same +freedoms that you received. You must make sure that they, too, receive +or can get the source code. And you must show them these terms so they +know their rights. + + Developers that use the GNU GPL protect your rights with two steps: +(1) assert copyright on the software, and (2) offer you this License +giving you legal permission to copy, distribute and/or modify it. + + For the developers' and authors' protection, the GPL clearly explains +that there is no warranty for this free software. For both users' and +authors' sake, the GPL requires that modified versions be marked as +changed, so that their problems will not be attributed erroneously to +authors of previous versions. + + Some devices are designed to deny users access to install or run +modified versions of the software inside them, although the manufacturer +can do so. This is fundamentally incompatible with the aim of +protecting users' freedom to change the software. The systematic +pattern of such abuse occurs in the area of products for individuals to +use, which is precisely where it is most unacceptable. Therefore, we +have designed this version of the GPL to prohibit the practice for those +products. If such problems arise substantially in other domains, we +stand ready to extend this provision to those domains in future versions +of the GPL, as needed to protect the freedom of users. + + Finally, every program is threatened constantly by software patents. +States should not allow patents to restrict development and use of +software on general-purpose computers, but in those that do, we wish to +avoid the special danger that patents applied to a free program could +make it effectively proprietary. To prevent this, the GPL assures that +patents cannot be used to render the program non-free. + + The precise terms and conditions for copying, distribution and +modification follow. + + TERMS AND CONDITIONS + + 0. Definitions. + + "This License" refers to version 3 of the GNU General Public License. + + "Copyright" also means copyright-like laws that apply to other kinds of +works, such as semiconductor masks. + + "The Program" refers to any copyrightable work licensed under this +License. Each licensee is addressed as "you". "Licensees" and +"recipients" may be individuals or organizations. + + To "modify" a work means to copy from or adapt all or part of the work +in a fashion requiring copyright permission, other than the making of an +exact copy. The resulting work is called a "modified version" of the +earlier work or a work "based on" the earlier work. + + A "covered work" means either the unmodified Program or a work based +on the Program. + + To "propagate" a work means to do anything with it that, without +permission, would make you directly or secondarily liable for +infringement under applicable copyright law, except executing it on a +computer or modifying a private copy. Propagation includes copying, +distribution (with or without modification), making available to the +public, and in some countries other activities as well. + + To "convey" a work means any kind of propagation that enables other +parties to make or receive copies. Mere interaction with a user through +a computer network, with no transfer of a copy, is not conveying. + + An interactive user interface displays "Appropriate Legal Notices" +to the extent that it includes a convenient and prominently visible +feature that (1) displays an appropriate copyright notice, and (2) +tells the user that there is no warranty for the work (except to the +extent that warranties are provided), that licensees may convey the +work under this License, and how to view a copy of this License. If +the interface presents a list of user commands or options, such as a +menu, a prominent item in the list meets this criterion. + + 1. Source Code. + + The "source code" for a work means the preferred form of the work +for making modifications to it. "Object code" means any non-source +form of a work. + + A "Standard Interface" means an interface that either is an official +standard defined by a recognized standards body, or, in the case of +interfaces specified for a particular programming language, one that +is widely used among developers working in that language. + + The "System Libraries" of an executable work include anything, other +than the work as a whole, that (a) is included in the normal form of +packaging a Major Component, but which is not part of that Major +Component, and (b) serves only to enable use of the work with that +Major Component, or to implement a Standard Interface for which an +implementation is available to the public in source code form. A +"Major Component", in this context, means a major essential component +(kernel, window system, and so on) of the specific operating system +(if any) on which the executable work runs, or a compiler used to +produce the work, or an object code interpreter used to run it. + + The "Corresponding Source" for a work in object code form means all +the source code needed to generate, install, and (for an executable +work) run the object code and to modify the work, including scripts to +control those activities. However, it does not include the work's +System Libraries, or general-purpose tools or generally available free +programs which are used unmodified in performing those activities but +which are not part of the work. For example, Corresponding Source +includes interface definition files associated with source files for +the work, and the source code for shared libraries and dynamically +linked subprograms that the work is specifically designed to require, +such as by intimate data communication or control flow between those +subprograms and other parts of the work. + + The Corresponding Source need not include anything that users +can regenerate automatically from other parts of the Corresponding +Source. + + The Corresponding Source for a work in source code form is that +same work. + + 2. Basic Permissions. + + All rights granted under this License are granted for the term of +copyright on the Program, and are irrevocable provided the stated +conditions are met. This License explicitly affirms your unlimited +permission to run the unmodified Program. The output from running a +covered work is covered by this License only if the output, given its +content, constitutes a covered work. This License acknowledges your +rights of fair use or other equivalent, as provided by copyright law. + + You may make, run and propagate covered works that you do not +convey, without conditions so long as your license otherwise remains +in force. You may convey covered works to others for the sole purpose +of having them make modifications exclusively for you, or provide you +with facilities for running those works, provided that you comply with +the terms of this License in conveying all material for which you do +not control copyright. Those thus making or running the covered works +for you must do so exclusively on your behalf, under your direction +and control, on terms that prohibit them from making any copies of +your copyrighted material outside their relationship with you. + + Conveying under any other circumstances is permitted solely under +the conditions stated below. Sublicensing is not allowed; section 10 +makes it unnecessary. + + 3. Protecting Users' Legal Rights From Anti-Circumvention Law. + + No covered work shall be deemed part of an effective technological +measure under any applicable law fulfilling obligations under article +11 of the WIPO copyright treaty adopted on 20 December 1996, or +similar laws prohibiting or restricting circumvention of such +measures. + + When you convey a covered work, you waive any legal power to forbid +circumvention of technological measures to the extent such circumvention +is effected by exercising rights under this License with respect to +the covered work, and you disclaim any intention to limit operation or +modification of the work as a means of enforcing, against the work's +users, your or third parties' legal rights to forbid circumvention of +technological measures. + + 4. Conveying Verbatim Copies. + + You may convey verbatim copies of the Program's source code as you +receive it, in any medium, provided that you conspicuously and +appropriately publish on each copy an appropriate copyright notice; +keep intact all notices stating that this License and any +non-permissive terms added in accord with section 7 apply to the code; +keep intact all notices of the absence of any warranty; and give all +recipients a copy of this License along with the Program. + + You may charge any price or no price for each copy that you convey, +and you may offer support or warranty protection for a fee. + + 5. Conveying Modified Source Versions. + + You may convey a work based on the Program, or the modifications to +produce it from the Program, in the form of source code under the +terms of section 4, provided that you also meet all of these conditions: + + a) The work must carry prominent notices stating that you modified + it, and giving a relevant date. + + b) The work must carry prominent notices stating that it is + released under this License and any conditions added under section + 7. This requirement modifies the requirement in section 4 to + "keep intact all notices". + + c) You must license the entire work, as a whole, under this + License to anyone who comes into possession of a copy. This + License will therefore apply, along with any applicable section 7 + additional terms, to the whole of the work, and all its parts, + regardless of how they are packaged. This License gives no + permission to license the work in any other way, but it does not + invalidate such permission if you have separately received it. + + d) If the work has interactive user interfaces, each must display + Appropriate Legal Notices; however, if the Program has interactive + interfaces that do not display Appropriate Legal Notices, your + work need not make them do so. + + A compilation of a covered work with other separate and independent +works, which are not by their nature extensions of the covered work, +and which are not combined with it such as to form a larger program, +in or on a volume of a storage or distribution medium, is called an +"aggregate" if the compilation and its resulting copyright are not +used to limit the access or legal rights of the compilation's users +beyond what the individual works permit. Inclusion of a covered work +in an aggregate does not cause this License to apply to the other +parts of the aggregate. + + 6. Conveying Non-Source Forms. + + You may convey a covered work in object code form under the terms +of sections 4 and 5, provided that you also convey the +machine-readable Corresponding Source under the terms of this License, +in one of these ways: + + a) Convey the object code in, or embodied in, a physical product + (including a physical distribution medium), accompanied by the + Corresponding Source fixed on a durable physical medium + customarily used for software interchange. + + b) Convey the object code in, or embodied in, a physical product + (including a physical distribution medium), accompanied by a + written offer, valid for at least three years and valid for as + long as you offer spare parts or customer support for that product + model, to give anyone who possesses the object code either (1) a + copy of the Corresponding Source for all the software in the + product that is covered by this License, on a durable physical + medium customarily used for software interchange, for a price no + more than your reasonable cost of physically performing this + conveying of source, or (2) access to copy the + Corresponding Source from a network server at no charge. + + c) Convey individual copies of the object code with a copy of the + written offer to provide the Corresponding Source. This + alternative is allowed only occasionally and noncommercially, and + only if you received the object code with such an offer, in accord + with subsection 6b. + + d) Convey the object code by offering access from a designated + place (gratis or for a charge), and offer equivalent access to the + Corresponding Source in the same way through the same place at no + further charge. You need not require recipients to copy the + Corresponding Source along with the object code. If the place to + copy the object code is a network server, the Corresponding Source + may be on a different server (operated by you or a third party) + that supports equivalent copying facilities, provided you maintain + clear directions next to the object code saying where to find the + Corresponding Source. Regardless of what server hosts the + Corresponding Source, you remain obligated to ensure that it is + available for as long as needed to satisfy these requirements. + + e) Convey the object code using peer-to-peer transmission, provided + you inform other peers where the object code and Corresponding + Source of the work are being offered to the general public at no + charge under subsection 6d. + + A separable portion of the object code, whose source code is excluded +from the Corresponding Source as a System Library, need not be +included in conveying the object code work. + + A "User Product" is either (1) a "consumer product", which means any +tangible personal property which is normally used for personal, family, +or household purposes, or (2) anything designed or sold for incorporation +into a dwelling. In determining whether a product is a consumer product, +doubtful cases shall be resolved in favor of coverage. For a particular +product received by a particular user, "normally used" refers to a +typical or common use of that class of product, regardless of the status +of the particular user or of the way in which the particular user +actually uses, or expects or is expected to use, the product. A product +is a consumer product regardless of whether the product has substantial +commercial, industrial or non-consumer uses, unless such uses represent +the only significant mode of use of the product. + + "Installation Information" for a User Product means any methods, +procedures, authorization keys, or other information required to install +and execute modified versions of a covered work in that User Product from +a modified version of its Corresponding Source. The information must +suffice to ensure that the continued functioning of the modified object +code is in no case prevented or interfered with solely because +modification has been made. + + If you convey an object code work under this section in, or with, or +specifically for use in, a User Product, and the conveying occurs as +part of a transaction in which the right of possession and use of the +User Product is transferred to the recipient in perpetuity or for a +fixed term (regardless of how the transaction is characterized), the +Corresponding Source conveyed under this section must be accompanied +by the Installation Information. But this requirement does not apply +if neither you nor any third party retains the ability to install +modified object code on the User Product (for example, the work has +been installed in ROM). + + The requirement to provide Installation Information does not include a +requirement to continue to provide support service, warranty, or updates +for a work that has been modified or installed by the recipient, or for +the User Product in which it has been modified or installed. Access to a +network may be denied when the modification itself materially and +adversely affects the operation of the network or violates the rules and +protocols for communication across the network. + + Corresponding Source conveyed, and Installation Information provided, +in accord with this section must be in a format that is publicly +documented (and with an implementation available to the public in +source code form), and must require no special password or key for +unpacking, reading or copying. + + 7. Additional Terms. + + "Additional permissions" are terms that supplement the terms of this +License by making exceptions from one or more of its conditions. +Additional permissions that are applicable to the entire Program shall +be treated as though they were included in this License, to the extent +that they are valid under applicable law. If additional permissions +apply only to part of the Program, that part may be used separately +under those permissions, but the entire Program remains governed by +this License without regard to the additional permissions. + + When you convey a copy of a covered work, you may at your option +remove any additional permissions from that copy, or from any part of +it. (Additional permissions may be written to require their own +removal in certain cases when you modify the work.) You may place +additional permissions on material, added by you to a covered work, +for which you have or can give appropriate copyright permission. + + Notwithstanding any other provision of this License, for material you +add to a covered work, you may (if authorized by the copyright holders of +that material) supplement the terms of this License with terms: + + a) Disclaiming warranty or limiting liability differently from the + terms of sections 15 and 16 of this License; or + + b) Requiring preservation of specified reasonable legal notices or + author attributions in that material or in the Appropriate Legal + Notices displayed by works containing it; or + + c) Prohibiting misrepresentation of the origin of that material, or + requiring that modified versions of such material be marked in + reasonable ways as different from the original version; or + + d) Limiting the use for publicity purposes of names of licensors or + authors of the material; or + + e) Declining to grant rights under trademark law for use of some + trade names, trademarks, or service marks; or + + f) Requiring indemnification of licensors and authors of that + material by anyone who conveys the material (or modified versions of + it) with contractual assumptions of liability to the recipient, for + any liability that these contractual assumptions directly impose on + those licensors and authors. + + All other non-permissive additional terms are considered "further +restrictions" within the meaning of section 10. If the Program as you +received it, or any part of it, contains a notice stating that it is +governed by this License along with a term that is a further +restriction, you may remove that term. If a license document contains +a further restriction but permits relicensing or conveying under this +License, you may add to a covered work material governed by the terms +of that license document, provided that the further restriction does +not survive such relicensing or conveying. + + If you add terms to a covered work in accord with this section, you +must place, in the relevant source files, a statement of the +additional terms that apply to those files, or a notice indicating +where to find the applicable terms. + + Additional terms, permissive or non-permissive, may be stated in the +form of a separately written license, or stated as exceptions; +the above requirements apply either way. + + 8. Termination. + + You may not propagate or modify a covered work except as expressly +provided under this License. Any attempt otherwise to propagate or +modify it is void, and will automatically terminate your rights under +this License (including any patent licenses granted under the third +paragraph of section 11). + + However, if you cease all violation of this License, then your +license from a particular copyright holder is reinstated (a) +provisionally, unless and until the copyright holder explicitly and +finally terminates your license, and (b) permanently, if the copyright +holder fails to notify you of the violation by some reasonable means +prior to 60 days after the cessation. + + Moreover, your license from a particular copyright holder is +reinstated permanently if the copyright holder notifies you of the +violation by some reasonable means, this is the first time you have +received notice of violation of this License (for any work) from that +copyright holder, and you cure the violation prior to 30 days after +your receipt of the notice. + + Termination of your rights under this section does not terminate the +licenses of parties who have received copies or rights from you under +this License. If your rights have been terminated and not permanently +reinstated, you do not qualify to receive new licenses for the same +material under section 10. + + 9. Acceptance Not Required for Having Copies. + + You are not required to accept this License in order to receive or +run a copy of the Program. Ancillary propagation of a covered work +occurring solely as a consequence of using peer-to-peer transmission +to receive a copy likewise does not require acceptance. However, +nothing other than this License grants you permission to propagate or +modify any covered work. These actions infringe copyright if you do +not accept this License. Therefore, by modifying or propagating a +covered work, you indicate your acceptance of this License to do so. + + 10. Automatic Licensing of Downstream Recipients. + + Each time you convey a covered work, the recipient automatically +receives a license from the original licensors, to run, modify and +propagate that work, subject to this License. You are not responsible +for enforcing compliance by third parties with this License. + + An "entity transaction" is a transaction transferring control of an +organization, or substantially all assets of one, or subdividing an +organization, or merging organizations. If propagation of a covered +work results from an entity transaction, each party to that +transaction who receives a copy of the work also receives whatever +licenses to the work the party's predecessor in interest had or could +give under the previous paragraph, plus a right to possession of the +Corresponding Source of the work from the predecessor in interest, if +the predecessor has it or can get it with reasonable efforts. + + You may not impose any further restrictions on the exercise of the +rights granted or affirmed under this License. For example, you may +not impose a license fee, royalty, or other charge for exercise of +rights granted under this License, and you may not initiate litigation +(including a cross-claim or counterclaim in a lawsuit) alleging that +any patent claim is infringed by making, using, selling, offering for +sale, or importing the Program or any portion of it. + + 11. Patents. + + A "contributor" is a copyright holder who authorizes use under this +License of the Program or a work on which the Program is based. The +work thus licensed is called the contributor's "contributor version". + + A contributor's "essential patent claims" are all patent claims +owned or controlled by the contributor, whether already acquired or +hereafter acquired, that would be infringed by some manner, permitted +by this License, of making, using, or selling its contributor version, +but do not include claims that would be infringed only as a +consequence of further modification of the contributor version. For +purposes of this definition, "control" includes the right to grant +patent sublicenses in a manner consistent with the requirements of +this License. + + Each contributor grants you a non-exclusive, worldwide, royalty-free +patent license under the contributor's essential patent claims, to +make, use, sell, offer for sale, import and otherwise run, modify and +propagate the contents of its contributor version. + + In the following three paragraphs, a "patent license" is any express +agreement or commitment, however denominated, not to enforce a patent +(such as an express permission to practice a patent or covenant not to +sue for patent infringement). To "grant" such a patent license to a +party means to make such an agreement or commitment not to enforce a +patent against the party. + + If you convey a covered work, knowingly relying on a patent license, +and the Corresponding Source of the work is not available for anyone +to copy, free of charge and under the terms of this License, through a +publicly available network server or other readily accessible means, +then you must either (1) cause the Corresponding Source to be so +available, or (2) arrange to deprive yourself of the benefit of the +patent license for this particular work, or (3) arrange, in a manner +consistent with the requirements of this License, to extend the patent +license to downstream recipients. "Knowingly relying" means you have +actual knowledge that, but for the patent license, your conveying the +covered work in a country, or your recipient's use of the covered work +in a country, would infringe one or more identifiable patents in that +country that you have reason to believe are valid. + + If, pursuant to or in connection with a single transaction or +arrangement, you convey, or propagate by procuring conveyance of, a +covered work, and grant a patent license to some of the parties +receiving the covered work authorizing them to use, propagate, modify +or convey a specific copy of the covered work, then the patent license +you grant is automatically extended to all recipients of the covered +work and works based on it. + + A patent license is "discriminatory" if it does not include within +the scope of its coverage, prohibits the exercise of, or is +conditioned on the non-exercise of one or more of the rights that are +specifically granted under this License. You may not convey a covered +work if you are a party to an arrangement with a third party that is +in the business of distributing software, under which you make payment +to the third party based on the extent of your activity of conveying +the work, and under which the third party grants, to any of the +parties who would receive the covered work from you, a discriminatory +patent license (a) in connection with copies of the covered work +conveyed by you (or copies made from those copies), or (b) primarily +for and in connection with specific products or compilations that +contain the covered work, unless you entered into that arrangement, +or that patent license was granted, prior to 28 March 2007. + + Nothing in this License shall be construed as excluding or limiting +any implied license or other defenses to infringement that may +otherwise be available to you under applicable patent law. + + 12. No Surrender of Others' Freedom. + + If conditions are imposed on you (whether by court order, agreement or +otherwise) that contradict the conditions of this License, they do not +excuse you from the conditions of this License. If you cannot convey a +covered work so as to satisfy simultaneously your obligations under this +License and any other pertinent obligations, then as a consequence you may +not convey it at all. For example, if you agree to terms that obligate you +to collect a royalty for further conveying from those to whom you convey +the Program, the only way you could satisfy both those terms and this +License would be to refrain entirely from conveying the Program. + + 13. Use with the GNU Affero General Public License. + + Notwithstanding any other provision of this License, you have +permission to link or combine any covered work with a work licensed +under version 3 of the GNU Affero General Public License into a single +combined work, and to convey the resulting work. The terms of this +License will continue to apply to the part which is the covered work, +but the special requirements of the GNU Affero General Public License, +section 13, concerning interaction through a network will apply to the +combination as such. + + 14. Revised Versions of this License. + + The Free Software Foundation may publish revised and/or new versions of +the GNU General Public License from time to time. Such new versions will +be similar in spirit to the present version, but may differ in detail to +address new problems or concerns. + + Each version is given a distinguishing version number. If the +Program specifies that a certain numbered version of the GNU General +Public License "or any later version" applies to it, you have the +option of following the terms and conditions either of that numbered +version or of any later version published by the Free Software +Foundation. If the Program does not specify a version number of the +GNU General Public License, you may choose any version ever published +by the Free Software Foundation. + + If the Program specifies that a proxy can decide which future +versions of the GNU General Public License can be used, that proxy's +public statement of acceptance of a version permanently authorizes you +to choose that version for the Program. + + Later license versions may give you additional or different +permissions. However, no additional obligations are imposed on any +author or copyright holder as a result of your choosing to follow a +later version. + + 15. Disclaimer of Warranty. + + THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY +APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT +HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY +OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, +THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM +IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF +ALL NECESSARY SERVICING, REPAIR OR CORRECTION. + + 16. Limitation of Liability. + + IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING +WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS +THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY +GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE +USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF +DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD +PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), +EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF +SUCH DAMAGES. + + 17. Interpretation of Sections 15 and 16. + + If the disclaimer of warranty and limitation of liability provided +above cannot be given local legal effect according to their terms, +reviewing courts shall apply local law that most closely approximates +an absolute waiver of all civil liability in connection with the +Program, unless a warranty or assumption of liability accompanies a +copy of the Program in return for a fee. + + END OF TERMS AND CONDITIONS + + How to Apply These Terms to Your New Programs + + If you develop a new program, and you want it to be of the greatest +possible use to the public, the best way to achieve this is to make it +free software which everyone can redistribute and change under these terms. + + To do so, attach the following notices to the program. It is safest +to attach them to the start of each source file to most effectively +state the exclusion of warranty; and each file should have at least +the "copyright" line and a pointer to where the full notice is found. + + + Copyright (C) + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . + +Also add information on how to contact you by electronic and paper mail. + + If the program does terminal interaction, make it output a short +notice like this when it starts in an interactive mode: + + Copyright (C) + This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'. + This is free software, and you are welcome to redistribute it + under certain conditions; type `show c' for details. + +The hypothetical commands `show w' and `show c' should show the appropriate +parts of the General Public License. Of course, your program's commands +might be different; for a GUI interface, you would use an "about box". + + You should also get your employer (if you work as a programmer) or school, +if any, to sign a "copyright disclaimer" for the program, if necessary. +For more information on this, and how to apply and follow the GNU GPL, see +. + + The GNU General Public License does not permit incorporating your program +into proprietary programs. If your program is a subroutine library, you +may consider it more useful to permit linking proprietary applications with +the library. If this is what you want to do, use the GNU Lesser General +Public License instead of this License. But first, please read +. GNU GENERAL PUBLIC LICENSE + Version 3, 29 June 2007 + + Copyright (C) 2007 Free Software Foundation, Inc. + Everyone is permitted to copy and distribute verbatim copies + of this license document, but changing it is not allowed. + + Preamble + + The GNU General Public License is a free, copyleft license for +software and other kinds of works. + + The licenses for most software and other practical works are designed +to take away your freedom to share and change the works. By contrast, +the GNU General Public License is intended to guarantee your freedom to +share and change all versions of a program--to make sure it remains free +software for all its users. We, the Free Software Foundation, use the +GNU General Public License for most of our software; it applies also to +any other work released this way by its authors. You can apply it to +your programs, too. + + When we speak of free software, we are referring to freedom, not +price. Our General Public Licenses are designed to make sure that you +have the freedom to distribute copies of free software (and charge for +them if you wish), that you receive source code or can get it if you +want it, that you can change the software or use pieces of it in new +free programs, and that you know you can do these things. + + To protect your rights, we need to prevent others from denying you +these rights or asking you to surrender the rights. Therefore, you have +certain responsibilities if you distribute copies of the software, or if +you modify it: responsibilities to respect the freedom of others. + + For example, if you distribute copies of such a program, whether +gratis or for a fee, you must pass on to the recipients the same +freedoms that you received. You must make sure that they, too, receive +or can get the source code. And you must show them these terms so they +know their rights. + + Developers that use the GNU GPL protect your rights with two steps: +(1) assert copyright on the software, and (2) offer you this License +giving you legal permission to copy, distribute and/or modify it. + + For the developers' and authors' protection, the GPL clearly explains +that there is no warranty for this free software. For both users' and +authors' sake, the GPL requires that modified versions be marked as +changed, so that their problems will not be attributed erroneously to +authors of previous versions. + + Some devices are designed to deny users access to install or run +modified versions of the software inside them, although the manufacturer +can do so. This is fundamentally incompatible with the aim of +protecting users' freedom to change the software. The systematic +pattern of such abuse occurs in the area of products for individuals to +use, which is precisely where it is most unacceptable. Therefore, we +have designed this version of the GPL to prohibit the practice for those +products. If such problems arise substantially in other domains, we +stand ready to extend this provision to those domains in future versions +of the GPL, as needed to protect the freedom of users. + + Finally, every program is threatened constantly by software patents. +States should not allow patents to restrict development and use of +software on general-purpose computers, but in those that do, we wish to +avoid the special danger that patents applied to a free program could +make it effectively proprietary. To prevent this, the GPL assures that +patents cannot be used to render the program non-free. + + The precise terms and conditions for copying, distribution and +modification follow. + + TERMS AND CONDITIONS + + 0. Definitions. + + "This License" refers to version 3 of the GNU General Public License. + + "Copyright" also means copyright-like laws that apply to other kinds of +works, such as semiconductor masks. + + "The Program" refers to any copyrightable work licensed under this +License. Each licensee is addressed as "you". "Licensees" and +"recipients" may be individuals or organizations. + + To "modify" a work means to copy from or adapt all or part of the work +in a fashion requiring copyright permission, other than the making of an +exact copy. The resulting work is called a "modified version" of the +earlier work or a work "based on" the earlier work. + + A "covered work" means either the unmodified Program or a work based +on the Program. + + To "propagate" a work means to do anything with it that, without +permission, would make you directly or secondarily liable for +infringement under applicable copyright law, except executing it on a +computer or modifying a private copy. Propagation includes copying, +distribution (with or without modification), making available to the +public, and in some countries other activities as well. + + To "convey" a work means any kind of propagation that enables other +parties to make or receive copies. Mere interaction with a user through +a computer network, with no transfer of a copy, is not conveying. + + An interactive user interface displays "Appropriate Legal Notices" +to the extent that it includes a convenient and prominently visible +feature that (1) displays an appropriate copyright notice, and (2) +tells the user that there is no warranty for the work (except to the +extent that warranties are provided), that licensees may convey the +work under this License, and how to view a copy of this License. If +the interface presents a list of user commands or options, such as a +menu, a prominent item in the list meets this criterion. + + 1. Source Code. + + The "source code" for a work means the preferred form of the work +for making modifications to it. "Object code" means any non-source +form of a work. + + A "Standard Interface" means an interface that either is an official +standard defined by a recognized standards body, or, in the case of +interfaces specified for a particular programming language, one that +is widely used among developers working in that language. + + The "System Libraries" of an executable work include anything, other +than the work as a whole, that (a) is included in the normal form of +packaging a Major Component, but which is not part of that Major +Component, and (b) serves only to enable use of the work with that +Major Component, or to implement a Standard Interface for which an +implementation is available to the public in source code form. A +"Major Component", in this context, means a major essential component +(kernel, window system, and so on) of the specific operating system +(if any) on which the executable work runs, or a compiler used to +produce the work, or an object code interpreter used to run it. + + The "Corresponding Source" for a work in object code form means all +the source code needed to generate, install, and (for an executable +work) run the object code and to modify the work, including scripts to +control those activities. However, it does not include the work's +System Libraries, or general-purpose tools or generally available free +programs which are used unmodified in performing those activities but +which are not part of the work. For example, Corresponding Source +includes interface definition files associated with source files for +the work, and the source code for shared libraries and dynamically +linked subprograms that the work is specifically designed to require, +such as by intimate data communication or control flow between those +subprograms and other parts of the work. + + The Corresponding Source need not include anything that users +can regenerate automatically from other parts of the Corresponding +Source. + + The Corresponding Source for a work in source code form is that +same work. + + 2. Basic Permissions. + + All rights granted under this License are granted for the term of +copyright on the Program, and are irrevocable provided the stated +conditions are met. This License explicitly affirms your unlimited +permission to run the unmodified Program. The output from running a +covered work is covered by this License only if the output, given its +content, constitutes a covered work. This License acknowledges your +rights of fair use or other equivalent, as provided by copyright law. + + You may make, run and propagate covered works that you do not +convey, without conditions so long as your license otherwise remains +in force. You may convey covered works to others for the sole purpose +of having them make modifications exclusively for you, or provide you +with facilities for running those works, provided that you comply with +the terms of this License in conveying all material for which you do +not control copyright. Those thus making or running the covered works +for you must do so exclusively on your behalf, under your direction +and control, on terms that prohibit them from making any copies of +your copyrighted material outside their relationship with you. + + Conveying under any other circumstances is permitted solely under +the conditions stated below. Sublicensing is not allowed; section 10 +makes it unnecessary. + + 3. Protecting Users' Legal Rights From Anti-Circumvention Law. + + No covered work shall be deemed part of an effective technological +measure under any applicable law fulfilling obligations under article +11 of the WIPO copyright treaty adopted on 20 December 1996, or +similar laws prohibiting or restricting circumvention of such +measures. + + When you convey a covered work, you waive any legal power to forbid +circumvention of technological measures to the extent such circumvention +is effected by exercising rights under this License with respect to +the covered work, and you disclaim any intention to limit operation or +modification of the work as a means of enforcing, against the work's +users, your or third parties' legal rights to forbid circumvention of +technological measures. + + 4. Conveying Verbatim Copies. + + You may convey verbatim copies of the Program's source code as you +receive it, in any medium, provided that you conspicuously and +appropriately publish on each copy an appropriate copyright notice; +keep intact all notices stating that this License and any +non-permissive terms added in accord with section 7 apply to the code; +keep intact all notices of the absence of any warranty; and give all +recipients a copy of this License along with the Program. + + You may charge any price or no price for each copy that you convey, +and you may offer support or warranty protection for a fee. + + 5. Conveying Modified Source Versions. + + You may convey a work based on the Program, or the modifications to +produce it from the Program, in the form of source code under the +terms of section 4, provided that you also meet all of these conditions: + + a) The work must carry prominent notices stating that you modified + it, and giving a relevant date. + + b) The work must carry prominent notices stating that it is + released under this License and any conditions added under section + 7. This requirement modifies the requirement in section 4 to + "keep intact all notices". + + c) You must license the entire work, as a whole, under this + License to anyone who comes into possession of a copy. This + License will therefore apply, along with any applicable section 7 + additional terms, to the whole of the work, and all its parts, + regardless of how they are packaged. This License gives no + permission to license the work in any other way, but it does not + invalidate such permission if you have separately received it. + + d) If the work has interactive user interfaces, each must display + Appropriate Legal Notices; however, if the Program has interactive + interfaces that do not display Appropriate Legal Notices, your + work need not make them do so. + + A compilation of a covered work with other separate and independent +works, which are not by their nature extensions of the covered work, +and which are not combined with it such as to form a larger program, +in or on a volume of a storage or distribution medium, is called an +"aggregate" if the compilation and its resulting copyright are not +used to limit the access or legal rights of the compilation's users +beyond what the individual works permit. Inclusion of a covered work +in an aggregate does not cause this License to apply to the other +parts of the aggregate. + + 6. Conveying Non-Source Forms. + + You may convey a covered work in object code form under the terms +of sections 4 and 5, provided that you also convey the +machine-readable Corresponding Source under the terms of this License, +in one of these ways: + + a) Convey the object code in, or embodied in, a physical product + (including a physical distribution medium), accompanied by the + Corresponding Source fixed on a durable physical medium + customarily used for software interchange. + + b) Convey the object code in, or embodied in, a physical product + (including a physical distribution medium), accompanied by a + written offer, valid for at least three years and valid for as + long as you offer spare parts or customer support for that product + model, to give anyone who possesses the object code either (1) a + copy of the Corresponding Source for all the software in the + product that is covered by this License, on a durable physical + medium customarily used for software interchange, for a price no + more than your reasonable cost of physically performing this + conveying of source, or (2) access to copy the + Corresponding Source from a network server at no charge. + + c) Convey individual copies of the object code with a copy of the + written offer to provide the Corresponding Source. This + alternative is allowed only occasionally and noncommercially, and + only if you received the object code with such an offer, in accord + with subsection 6b. + + d) Convey the object code by offering access from a designated + place (gratis or for a charge), and offer equivalent access to the + Corresponding Source in the same way through the same place at no + further charge. You need not require recipients to copy the + Corresponding Source along with the object code. If the place to + copy the object code is a network server, the Corresponding Source + may be on a different server (operated by you or a third party) + that supports equivalent copying facilities, provided you maintain + clear directions next to the object code saying where to find the + Corresponding Source. Regardless of what server hosts the + Corresponding Source, you remain obligated to ensure that it is + available for as long as needed to satisfy these requirements. + + e) Convey the object code using peer-to-peer transmission, provided + you inform other peers where the object code and Corresponding + Source of the work are being offered to the general public at no + charge under subsection 6d. + + A separable portion of the object code, whose source code is excluded +from the Corresponding Source as a System Library, need not be +included in conveying the object code work. + + A "User Product" is either (1) a "consumer product", which means any +tangible personal property which is normally used for personal, family, +or household purposes, or (2) anything designed or sold for incorporation +into a dwelling. In determining whether a product is a consumer product, +doubtful cases shall be resolved in favor of coverage. For a particular +product received by a particular user, "normally used" refers to a +typical or common use of that class of product, regardless of the status +of the particular user or of the way in which the particular user +actually uses, or expects or is expected to use, the product. A product +is a consumer product regardless of whether the product has substantial +commercial, industrial or non-consumer uses, unless such uses represent +the only significant mode of use of the product. + + "Installation Information" for a User Product means any methods, +procedures, authorization keys, or other information required to install +and execute modified versions of a covered work in that User Product from +a modified version of its Corresponding Source. The information must +suffice to ensure that the continued functioning of the modified object +code is in no case prevented or interfered with solely because +modification has been made. + + If you convey an object code work under this section in, or with, or +specifically for use in, a User Product, and the conveying occurs as +part of a transaction in which the right of possession and use of the +User Product is transferred to the recipient in perpetuity or for a +fixed term (regardless of how the transaction is characterized), the +Corresponding Source conveyed under this section must be accompanied +by the Installation Information. But this requirement does not apply +if neither you nor any third party retains the ability to install +modified object code on the User Product (for example, the work has +been installed in ROM). + + The requirement to provide Installation Information does not include a +requirement to continue to provide support service, warranty, or updates +for a work that has been modified or installed by the recipient, or for +the User Product in which it has been modified or installed. Access to a +network may be denied when the modification itself materially and +adversely affects the operation of the network or violates the rules and +protocols for communication across the network. + + Corresponding Source conveyed, and Installation Information provided, +in accord with this section must be in a format that is publicly +documented (and with an implementation available to the public in +source code form), and must require no special password or key for +unpacking, reading or copying. + + 7. Additional Terms. + + "Additional permissions" are terms that supplement the terms of this +License by making exceptions from one or more of its conditions. +Additional permissions that are applicable to the entire Program shall +be treated as though they were included in this License, to the extent +that they are valid under applicable law. If additional permissions +apply only to part of the Program, that part may be used separately +under those permissions, but the entire Program remains governed by +this License without regard to the additional permissions. + + When you convey a copy of a covered work, you may at your option +remove any additional permissions from that copy, or from any part of +it. (Additional permissions may be written to require their own +removal in certain cases when you modify the work.) You may place +additional permissions on material, added by you to a covered work, +for which you have or can give appropriate copyright permission. + + Notwithstanding any other provision of this License, for material you +add to a covered work, you may (if authorized by the copyright holders of +that material) supplement the terms of this License with terms: + + a) Disclaiming warranty or limiting liability differently from the + terms of sections 15 and 16 of this License; or + + b) Requiring preservation of specified reasonable legal notices or + author attributions in that material or in the Appropriate Legal + Notices displayed by works containing it; or + + c) Prohibiting misrepresentation of the origin of that material, or + requiring that modified versions of such material be marked in + reasonable ways as different from the original version; or + + d) Limiting the use for publicity purposes of names of licensors or + authors of the material; or + + e) Declining to grant rights under trademark law for use of some + trade names, trademarks, or service marks; or + + f) Requiring indemnification of licensors and authors of that + material by anyone who conveys the material (or modified versions of + it) with contractual assumptions of liability to the recipient, for + any liability that these contractual assumptions directly impose on + those licensors and authors. + + All other non-permissive additional terms are considered "further +restrictions" within the meaning of section 10. If the Program as you +received it, or any part of it, contains a notice stating that it is +governed by this License along with a term that is a further +restriction, you may remove that term. If a license document contains +a further restriction but permits relicensing or conveying under this +License, you may add to a covered work material governed by the terms +of that license document, provided that the further restriction does +not survive such relicensing or conveying. + + If you add terms to a covered work in accord with this section, you +must place, in the relevant source files, a statement of the +additional terms that apply to those files, or a notice indicating +where to find the applicable terms. + + Additional terms, permissive or non-permissive, may be stated in the +form of a separately written license, or stated as exceptions; +the above requirements apply either way. + + 8. Termination. + + You may not propagate or modify a covered work except as expressly +provided under this License. Any attempt otherwise to propagate or +modify it is void, and will automatically terminate your rights under +this License (including any patent licenses granted under the third +paragraph of section 11). + + However, if you cease all violation of this License, then your +license from a particular copyright holder is reinstated (a) +provisionally, unless and until the copyright holder explicitly and +finally terminates your license, and (b) permanently, if the copyright +holder fails to notify you of the violation by some reasonable means +prior to 60 days after the cessation. + + Moreover, your license from a particular copyright holder is +reinstated permanently if the copyright holder notifies you of the +violation by some reasonable means, this is the first time you have +received notice of violation of this License (for any work) from that +copyright holder, and you cure the violation prior to 30 days after +your receipt of the notice. + + Termination of your rights under this section does not terminate the +licenses of parties who have received copies or rights from you under +this License. If your rights have been terminated and not permanently +reinstated, you do not qualify to receive new licenses for the same +material under section 10. + + 9. Acceptance Not Required for Having Copies. + + You are not required to accept this License in order to receive or +run a copy of the Program. Ancillary propagation of a covered work +occurring solely as a consequence of using peer-to-peer transmission +to receive a copy likewise does not require acceptance. However, +nothing other than this License grants you permission to propagate or +modify any covered work. These actions infringe copyright if you do +not accept this License. Therefore, by modifying or propagating a +covered work, you indicate your acceptance of this License to do so. + + 10. Automatic Licensing of Downstream Recipients. + + Each time you convey a covered work, the recipient automatically +receives a license from the original licensors, to run, modify and +propagate that work, subject to this License. You are not responsible +for enforcing compliance by third parties with this License. + + An "entity transaction" is a transaction transferring control of an +organization, or substantially all assets of one, or subdividing an +organization, or merging organizations. If propagation of a covered +work results from an entity transaction, each party to that +transaction who receives a copy of the work also receives whatever +licenses to the work the party's predecessor in interest had or could +give under the previous paragraph, plus a right to possession of the +Corresponding Source of the work from the predecessor in interest, if +the predecessor has it or can get it with reasonable efforts. + + You may not impose any further restrictions on the exercise of the +rights granted or affirmed under this License. For example, you may +not impose a license fee, royalty, or other charge for exercise of +rights granted under this License, and you may not initiate litigation +(including a cross-claim or counterclaim in a lawsuit) alleging that +any patent claim is infringed by making, using, selling, offering for +sale, or importing the Program or any portion of it. + + 11. Patents. + + A "contributor" is a copyright holder who authorizes use under this +License of the Program or a work on which the Program is based. The +work thus licensed is called the contributor's "contributor version". + + A contributor's "essential patent claims" are all patent claims +owned or controlled by the contributor, whether already acquired or +hereafter acquired, that would be infringed by some manner, permitted +by this License, of making, using, or selling its contributor version, +but do not include claims that would be infringed only as a +consequence of further modification of the contributor version. For +purposes of this definition, "control" includes the right to grant +patent sublicenses in a manner consistent with the requirements of +this License. + + Each contributor grants you a non-exclusive, worldwide, royalty-free +patent license under the contributor's essential patent claims, to +make, use, sell, offer for sale, import and otherwise run, modify and +propagate the contents of its contributor version. + + In the following three paragraphs, a "patent license" is any express +agreement or commitment, however denominated, not to enforce a patent +(such as an express permission to practice a patent or covenant not to +sue for patent infringement). To "grant" such a patent license to a +party means to make such an agreement or commitment not to enforce a +patent against the party. + + If you convey a covered work, knowingly relying on a patent license, +and the Corresponding Source of the work is not available for anyone +to copy, free of charge and under the terms of this License, through a +publicly available network server or other readily accessible means, +then you must either (1) cause the Corresponding Source to be so +available, or (2) arrange to deprive yourself of the benefit of the +patent license for this particular work, or (3) arrange, in a manner +consistent with the requirements of this License, to extend the patent +license to downstream recipients. "Knowingly relying" means you have +actual knowledge that, but for the patent license, your conveying the +covered work in a country, or your recipient's use of the covered work +in a country, would infringe one or more identifiable patents in that +country that you have reason to believe are valid. + + If, pursuant to or in connection with a single transaction or +arrangement, you convey, or propagate by procuring conveyance of, a +covered work, and grant a patent license to some of the parties +receiving the covered work authorizing them to use, propagate, modify +or convey a specific copy of the covered work, then the patent license +you grant is automatically extended to all recipients of the covered +work and works based on it. + + A patent license is "discriminatory" if it does not include within +the scope of its coverage, prohibits the exercise of, or is +conditioned on the non-exercise of one or more of the rights that are +specifically granted under this License. You may not convey a covered +work if you are a party to an arrangement with a third party that is +in the business of distributing software, under which you make payment +to the third party based on the extent of your activity of conveying +the work, and under which the third party grants, to any of the +parties who would receive the covered work from you, a discriminatory +patent license (a) in connection with copies of the covered work +conveyed by you (or copies made from those copies), or (b) primarily +for and in connection with specific products or compilations that +contain the covered work, unless you entered into that arrangement, +or that patent license was granted, prior to 28 March 2007. + + Nothing in this License shall be construed as excluding or limiting +any implied license or other defenses to infringement that may +otherwise be available to you under applicable patent law. + + 12. No Surrender of Others' Freedom. + + If conditions are imposed on you (whether by court order, agreement or +otherwise) that contradict the conditions of this License, they do not +excuse you from the conditions of this License. If you cannot convey a +covered work so as to satisfy simultaneously your obligations under this +License and any other pertinent obligations, then as a consequence you may +not convey it at all. For example, if you agree to terms that obligate you +to collect a royalty for further conveying from those to whom you convey +the Program, the only way you could satisfy both those terms and this +License would be to refrain entirely from conveying the Program. + + 13. Use with the GNU Affero General Public License. + + Notwithstanding any other provision of this License, you have +permission to link or combine any covered work with a work licensed +under version 3 of the GNU Affero General Public License into a single +combined work, and to convey the resulting work. The terms of this +License will continue to apply to the part which is the covered work, +but the special requirements of the GNU Affero General Public License, +section 13, concerning interaction through a network will apply to the +combination as such. + + 14. Revised Versions of this License. + + The Free Software Foundation may publish revised and/or new versions of +the GNU General Public License from time to time. Such new versions will +be similar in spirit to the present version, but may differ in detail to +address new problems or concerns. + + Each version is given a distinguishing version number. If the +Program specifies that a certain numbered version of the GNU General +Public License "or any later version" applies to it, you have the +option of following the terms and conditions either of that numbered +version or of any later version published by the Free Software +Foundation. If the Program does not specify a version number of the +GNU General Public License, you may choose any version ever published +by the Free Software Foundation. + + If the Program specifies that a proxy can decide which future +versions of the GNU General Public License can be used, that proxy's +public statement of acceptance of a version permanently authorizes you +to choose that version for the Program. + + Later license versions may give you additional or different +permissions. However, no additional obligations are imposed on any +author or copyright holder as a result of your choosing to follow a +later version. + + 15. Disclaimer of Warranty. + + THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY +APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT +HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY +OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, +THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM +IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF +ALL NECESSARY SERVICING, REPAIR OR CORRECTION. + + 16. Limitation of Liability. + + IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING +WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS +THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY +GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE +USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF +DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD +PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), +EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF +SUCH DAMAGES. + + 17. Interpretation of Sections 15 and 16. + + If the disclaimer of warranty and limitation of liability provided +above cannot be given local legal effect according to their terms, +reviewing courts shall apply local law that most closely approximates +an absolute waiver of all civil liability in connection with the +Program, unless a warranty or assumption of liability accompanies a +copy of the Program in return for a fee. + + END OF TERMS AND CONDITIONS + + How to Apply These Terms to Your New Programs + + If you develop a new program, and you want it to be of the greatest +possible use to the public, the best way to achieve this is to make it +free software which everyone can redistribute and change under these terms. + + To do so, attach the following notices to the program. It is safest +to attach them to the start of each source file to most effectively +state the exclusion of warranty; and each file should have at least +the "copyright" line and a pointer to where the full notice is found. + + + Copyright (C) + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . + +Also add information on how to contact you by electronic and paper mail. + + If the program does terminal interaction, make it output a short +notice like this when it starts in an interactive mode: + + Copyright (C) + This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'. + This is free software, and you are welcome to redistribute it + under certain conditions; type `show c' for details. + +The hypothetical commands `show w' and `show c' should show the appropriate +parts of the General Public License. Of course, your program's commands +might be different; for a GUI interface, you would use an "about box". + + You should also get your employer (if you work as a programmer) or school, +if any, to sign a "copyright disclaimer" for the program, if necessary. +For more information on this, and how to apply and follow the GNU GPL, see +. + + The GNU General Public License does not permit incorporating your program +into proprietary programs. If your program is a subroutine library, you +may consider it more useful to permit linking proprietary applications with +the library. If this is what you want to do, use the GNU Lesser General +Public License instead of this License. But first, please read +. diff --git a/gulagcleaner_rs/src/lib.rs b/gulagcleaner_rs/src/lib.rs new file mode 100644 index 0000000..cd02e2a --- /dev/null +++ b/gulagcleaner_rs/src/lib.rs @@ -0,0 +1,301 @@ +//Here I should place my gulagcleaner-rust functions, and then call clean_pdf from python_binder.rs + +pub mod method; + +pub mod page_type; + +use lopdf::{Dictionary, Document, Object, ObjectId}; + +use std::{collections::HashSet, error::Error}; + + + +pub fn clean_pdf(data: Vec,force_naive: u8) -> Vec { + + //Load the PDF into a Document + let mut doc = Document::load_mem(&data).unwrap(); + let pages = doc.get_pages(); + + //We first need to determine what method we're using, either "new" or "naive". We keep it like this to allow for future methods if needed. + + let method = method::Method::new(&doc, force_naive); + + //Each method should mark pages for deletion in to_delete and modify the contents of the pages. + + let (to_delete,method_code) = match method { + method::Method::New(content_list, to_delete) => { + println!("Using new method"); + let new_contents: Vec> = content_list + .iter() + .enumerate() + .map(|(i, x)| { + let pares = if x == content_list.last().unwrap() { + find_iobj_pairs(x, &content_list[i - 1]) + } else { + let check_if_00 = find_iobj_pairs(x, &content_list[i + 1]); + if check_if_00 != (0,0) { + check_if_00 + } else { + find_iobj_pairs(x, &content_list[i - 1]) + } + }; + + x[(pares.0) - 2..=(pares.1) + 3].to_vec() + }) + .collect(); + + let vector: Vec<(&u32, &(u32, u16))> = pages + .iter() + .filter(|x| doc.get_page_contents(*x.1).len() > 1) + .collect(); + for (i, page) in vector.iter().enumerate() { + let mutable_page = doc.get_object_mut(*page.1).unwrap().as_dict_mut().unwrap(); + let contents_objects: Vec = new_contents[i] + .iter() + .map(|x| Object::Reference(*x)) + .collect(); + + mutable_page.set(*b"Contents", lopdf::Object::Array(contents_objects)); + + mutable_page.set("Annots", Object::Array(vec![])); + let mediabox = mutable_page.get(b"MediaBox").unwrap().as_array().unwrap(); + + let height_offset = match mediabox[1].as_f32() { + Ok(h) => h, + _ => mediabox[1].as_i64().unwrap() as f32, + }; + let width_offset = match mediabox[0].as_f32() { + Ok(h) => h, + _ => mediabox[0].as_i64().unwrap() as f32, + }; + + let height = match mediabox[3].as_f32() { + Ok(h) => h, + _ => mediabox[3].as_i64().unwrap() as f32, + }; + let width = match mediabox[2].as_f32() { + Ok(h) => h, + _ => mediabox[2].as_i64().unwrap() as f32, + }; + + for _box in ["MediaBox", "ArtBox", "TrimBox", "CropBox", "BleedBox"] { + mutable_page.set( + _box, + Object::Array(vec![ + Object::Real(0.0), + Object::Real(0.0), + Object::Real(width - width_offset), + Object::Real(height - height_offset), + ]), + ); + }; + } + + + (to_delete,0) + } + method::Method::Naive => { + println!("Using naive method"); + let mut to_delete = Vec::new(); + + for page in &pages { + let page_type = page_type::PageType::get_page_type(&doc, page.1).unwrap_or_default(); + let mutable_page = doc.get_object_mut(*page.1).unwrap().as_dict_mut().unwrap(); + + let mediabox = mutable_page.get(b"MediaBox").unwrap().as_array().unwrap(); + let height_offset = match mediabox[1].as_f32() { + Ok(h) => h, + _ => mediabox[1].as_i64().unwrap() as f32, + }; + let width_offset = match mediabox[0].as_f32() { + Ok(h) => h, + _ => mediabox[0].as_i64().unwrap() as f32, + }; + + let height = match mediabox[3].as_f32() { + Ok(h) => h, + _ => mediabox[3].as_i64().unwrap() as f32, + }; + let width = match mediabox[2].as_f32() { + Ok(h) => h, + _ => mediabox[2].as_i64().unwrap() as f32, + }; + + match page_type { + page_type::PageType::FullPageAds => to_delete.push(*page.0), + page_type::PageType::Idk => to_delete.push(*page.0), + page_type::PageType::BannerAds => { + //1.141 + let scale = 1.124; + for _box in ["MediaBox", "ArtBox", "TrimBox", "CropBox", "BleedBox"] { + mutable_page.set( + _box, + Object::Array(vec![ + Object::Real(0.164 * (width-width_offset) + width_offset*scale), + Object::Real(0.031 * (height-height_offset) + height_offset*scale), + Object::Real(0.978 * (width-width_offset) * scale + width_offset*scale), + Object::Real(0.865 * (height-height_offset) * scale + height_offset*scale), + ]), + ); + }; + + let mut contents = doc.get_page_content(*page.1).unwrap(); + let mut new_contents = Vec::new(); + let c_prepend = "q\n1.124 0 0 1.124 0 0 cm\n".as_bytes(); + let c_append = "Q".as_bytes(); + + new_contents.extend_from_slice(c_prepend); + new_contents.append(&mut contents); + new_contents.extend_from_slice(c_append); + + doc.change_page_content(*page.1, new_contents).unwrap() + } + page_type::PageType::Watermark => { + for _box in ["MediaBox", "ArtBox", "TrimBox", "CropBox", "BleedBox"] { + mutable_page.set( + _box, + Object::Array(vec![ + Object::Real(0.015 * (width-width_offset) + width_offset), + Object::Real(0.05 * (height-height_offset) + height_offset), + Object::Real(0.95 * (width-width_offset) + width_offset), + Object::Real(0.98 * (height-height_offset) + height_offset), + ]), + ); + }; + } + } + } + + for page in &pages { + // remove the logo + let _ = remove_logo(&mut doc, page.1); + + + // remove the annotations + let mutable_page = doc.get_object_mut(*page.1).unwrap().as_dict_mut().unwrap(); + mutable_page.set("Annots", Object::Array(vec![])); + + } + + (to_delete,2) + } + }; + + //Delete the pages that we've marked for deletion. + for (offset, page) in to_delete.into_iter().enumerate() { + doc.delete_pages(&[page - offset as u32]); + } + //Save the document. + let mut return_stream = Vec::new(); + doc.save_to(&mut return_stream).unwrap(); + + return_stream.push(method_code); + return_stream + //doc.save_to("test.pdf").unwrap(); +} + +fn find_iobj_pairs(first_page: &[(u32, u16)], second_page: &[(u32, u16)]) -> (usize, usize) { + let unique_first_page: HashSet<&(u32, u16)> = first_page.iter().collect(); + let unique_second_page: HashSet<&(u32, u16)> = second_page.iter().collect(); + + let c: Vec<&&(u32, u16)> = unique_first_page + .intersection(&unique_second_page) + .collect(); + if c.len() != 2 { + return (0, 0); + } + let first_index = first_page.iter().position(|&r| r == **c[0]).unwrap(); + let second_index = first_page.iter().position(|&r| r == **c[1]).unwrap(); + + if first_index < second_index { + (first_index, second_index) + } else { + (second_index, first_index) + } +} + +fn get_xobjs<'a>(doc: &'a Document, page: &ObjectId) -> Result<&'a Dictionary, Box> { + + let resource = doc.get_page_resources(*page); + let resource_dict; + if resource.1.is_empty() { + resource_dict = resource.0.unwrap(); + } else { + resource_dict = doc.get_object(resource.1[0])?.as_dict()?; + } + + let xobjs = resource_dict + .get(b"XObject")? + .as_dict()?; + Ok(xobjs) +} + +fn get_objdict<'a>( + doc: &'a Document, + obj: (&Vec, &Object), +) -> Result<&'a Dictionary, Box> { + let objdict = &doc + .get_object(obj.1.as_reference().unwrap())? + .as_stream()? + .dict; + + Ok(objdict) +} + +fn get_images(doc: &Document, xobjs: &Dictionary) -> Result, Box> { + let mut images = Vec::new(); + + for obj in xobjs { + let objectdict = get_objdict(doc, obj)?; + + let subtype = objectdict.get(b"Subtype").unwrap().as_name().unwrap(); + let sub_s = String::from_utf8_lossy(subtype); + + if sub_s.starts_with("Image") { + images.push(( + objectdict.get(b"Height").unwrap().as_i64().unwrap(), + objectdict.get(b"Width").unwrap().as_i64().unwrap(), + )); + } + } + + Ok(images) +} + +fn remove_logo(doc: &mut Document, page: &ObjectId) -> Result<(), Box> { + let xobjs = get_xobjs(doc, page)?.clone(); + let images = get_images(doc, &xobjs)?; + + let has_logo = !page_type::LOGO_DIMS + .iter() + .collect::>() + .intersection(&images.iter().collect::>()) + .collect::>() + .is_empty(); + + if has_logo { + for obj in &xobjs { + let objectdict = get_objdict(doc, obj)?; + + let subtype = objectdict.get(b"Subtype")?.as_name()?; + + let sub_s = String::from_utf8_lossy(subtype); + if sub_s.starts_with("Image") + && page_type::LOGO_DIMS.contains(&( + objectdict.get(b"Height")?.as_i64()?, + objectdict.get(b"Width")?.as_i64()?, + )) + { + let mutable_page = &mut doc + .get_object_mut(obj.1.as_reference()?)? + .as_stream_mut()? + .dict; + mutable_page.set(*b"Height", 0); + } + { + } + } + } + + Ok(()) +} diff --git a/gulagcleaner_rs/src/method.rs b/gulagcleaner_rs/src/method.rs new file mode 100644 index 0000000..588e090 --- /dev/null +++ b/gulagcleaner_rs/src/method.rs @@ -0,0 +1,49 @@ +use std::collections::HashSet; + +use lopdf::Document; + +pub enum Method { + New(Vec>, Vec), + Naive +} + +impl Method { + pub fn new(doc: &Document, force_naive: u8) -> Self { + //0 for auto, 1 for new, 3 for naive + if force_naive == 1 { + return Self::Naive + } + let pages = doc.get_pages(); + let content_list: Vec> = pages + .iter() + .map(|x| doc.get_page_contents(*x.1)) + .filter(|x| x.len() > 1) + .collect(); + let to_delete: Vec = pages + .iter() + .filter(|x| { + let contents = doc.get_page_contents(*x.1); + + if contents.len() == 1 { + return true; + } else { + return false; + } + }) + .map(|x| *x.0) + .collect(); + + if content_list.len() > 1 + && content_list[0] + .iter() + .collect::>() + .intersection(&content_list[1].iter().collect::>()) + .collect::>() + .len() + > 1 + { + return Self::New(content_list, to_delete); + } + Self::Naive + } +} \ No newline at end of file diff --git a/gulagcleaner_rs/src/page_type.rs b/gulagcleaner_rs/src/page_type.rs new file mode 100644 index 0000000..15a2908 --- /dev/null +++ b/gulagcleaner_rs/src/page_type.rs @@ -0,0 +1,90 @@ +use std::{error::Error, collections::HashSet}; + +use lopdf::{Document, ObjectId}; + +use crate::{get_xobjs, get_images}; + +#[derive(Default)] +pub enum PageType { + BannerAds, + FullPageAds, + Watermark, + #[default] + Idk, +} + +pub const LOGO_DIMS: [(i64, i64); 3] = [(71, 390), (37, 203), (73, 390)]; + +const HORIZONTAL_BANNER_DIMS: [(i64, i64); 7] = [ + (247, 1414), + (213, 1219), + (215, 1219), + (249, 1414), + (217, 1240), + (147, 1757), + (221, 1240) +]; +const VERTICAL_BANNER_DIMS: [(i64, i64); 8] = [ + (1753, 170), + (1518, 248), + (1520, 147), + (1753, 177), + (1751, 171), + (1537, 147), + (1093, 217), + (1534, 150) +]; +const FULL_PAGE_DIMS: [(i64, i64); 7] = [ + (842, 595), + (1754, 1240), + (2526, 1785), + (1733, 1219), + (3508, 2480), + (2339, 1653), + (1785,2526), +]; + +impl PageType { + pub fn get_page_type(doc: &Document, page: &ObjectId) -> Result> { + let xobjs = get_xobjs(doc, page)?; + let images = get_images(doc, xobjs)?; + println!("Images: {:?}",images); + let has_logo = !LOGO_DIMS + .iter() + .collect::>() + .intersection(&images.iter().collect::>()) + .collect::>() + .is_empty(); + + let has_horizontal_banner = !HORIZONTAL_BANNER_DIMS + .iter() + .collect::>() + .intersection(&images.iter().collect::>()) + .collect::>() + .is_empty(); + + let has_vertical_banner = !VERTICAL_BANNER_DIMS + .iter() + .collect::>() + .intersection(&images.iter().collect::>()) + .collect::>() + .is_empty(); + + let has_full_page = !FULL_PAGE_DIMS + .iter() + .collect::>() + .intersection(&images.iter().collect::>()) + .collect::>() + .is_empty(); + + if has_horizontal_banner && has_vertical_banner { + Ok(PageType::BannerAds) + } else if has_full_page { + Ok(PageType::FullPageAds) + } else if has_logo { + Ok(PageType::Watermark) + } else { + Ok(PageType::Idk) + } + } +} \ No newline at end of file diff --git a/gulagcleaner_wasm/Cargo.toml b/gulagcleaner_wasm/Cargo.toml index d24d3de..4267aa3 100644 --- a/gulagcleaner_wasm/Cargo.toml +++ b/gulagcleaner_wasm/Cargo.toml @@ -18,4 +18,4 @@ crate-type = ["cdylib"] [dependencies] wasm-bindgen = "0.2" -gulagcleaner = { path = "../gulagcleaner" } \ No newline at end of file +gulagcleaner_rs = { path = "../gulagcleaner_rs" } \ No newline at end of file diff --git a/gulagcleaner_wasm/LICENSE b/gulagcleaner_wasm/LICENSE new file mode 100644 index 0000000..ca40b21 --- /dev/null +++ b/gulagcleaner_wasm/LICENSE @@ -0,0 +1,1347 @@ + GNU GENERAL PUBLIC LICENSE + Version 3, 29 June 2007 + + Copyright (C) 2007 Free Software Foundation, Inc. + Everyone is permitted to copy and distribute verbatim copies + of this license document, but changing it is not allowed. + + Preamble + + The GNU General Public License is a free, copyleft license for +software and other kinds of works. + + The licenses for most software and other practical works are designed +to take away your freedom to share and change the works. By contrast, +the GNU General Public License is intended to guarantee your freedom to +share and change all versions of a program--to make sure it remains free +software for all its users. We, the Free Software Foundation, use the +GNU General Public License for most of our software; it applies also to +any other work released this way by its authors. You can apply it to +your programs, too. + + When we speak of free software, we are referring to freedom, not +price. Our General Public Licenses are designed to make sure that you +have the freedom to distribute copies of free software (and charge for +them if you wish), that you receive source code or can get it if you +want it, that you can change the software or use pieces of it in new +free programs, and that you know you can do these things. + + To protect your rights, we need to prevent others from denying you +these rights or asking you to surrender the rights. Therefore, you have +certain responsibilities if you distribute copies of the software, or if +you modify it: responsibilities to respect the freedom of others. + + For example, if you distribute copies of such a program, whether +gratis or for a fee, you must pass on to the recipients the same +freedoms that you received. You must make sure that they, too, receive +or can get the source code. And you must show them these terms so they +know their rights. + + Developers that use the GNU GPL protect your rights with two steps: +(1) assert copyright on the software, and (2) offer you this License +giving you legal permission to copy, distribute and/or modify it. + + For the developers' and authors' protection, the GPL clearly explains +that there is no warranty for this free software. For both users' and +authors' sake, the GPL requires that modified versions be marked as +changed, so that their problems will not be attributed erroneously to +authors of previous versions. + + Some devices are designed to deny users access to install or run +modified versions of the software inside them, although the manufacturer +can do so. This is fundamentally incompatible with the aim of +protecting users' freedom to change the software. The systematic +pattern of such abuse occurs in the area of products for individuals to +use, which is precisely where it is most unacceptable. Therefore, we +have designed this version of the GPL to prohibit the practice for those +products. If such problems arise substantially in other domains, we +stand ready to extend this provision to those domains in future versions +of the GPL, as needed to protect the freedom of users. + + Finally, every program is threatened constantly by software patents. +States should not allow patents to restrict development and use of +software on general-purpose computers, but in those that do, we wish to +avoid the special danger that patents applied to a free program could +make it effectively proprietary. To prevent this, the GPL assures that +patents cannot be used to render the program non-free. + + The precise terms and conditions for copying, distribution and +modification follow. + + TERMS AND CONDITIONS + + 0. Definitions. + + "This License" refers to version 3 of the GNU General Public License. + + "Copyright" also means copyright-like laws that apply to other kinds of +works, such as semiconductor masks. + + "The Program" refers to any copyrightable work licensed under this +License. Each licensee is addressed as "you". "Licensees" and +"recipients" may be individuals or organizations. + + To "modify" a work means to copy from or adapt all or part of the work +in a fashion requiring copyright permission, other than the making of an +exact copy. The resulting work is called a "modified version" of the +earlier work or a work "based on" the earlier work. + + A "covered work" means either the unmodified Program or a work based +on the Program. + + To "propagate" a work means to do anything with it that, without +permission, would make you directly or secondarily liable for +infringement under applicable copyright law, except executing it on a +computer or modifying a private copy. Propagation includes copying, +distribution (with or without modification), making available to the +public, and in some countries other activities as well. + + To "convey" a work means any kind of propagation that enables other +parties to make or receive copies. Mere interaction with a user through +a computer network, with no transfer of a copy, is not conveying. + + An interactive user interface displays "Appropriate Legal Notices" +to the extent that it includes a convenient and prominently visible +feature that (1) displays an appropriate copyright notice, and (2) +tells the user that there is no warranty for the work (except to the +extent that warranties are provided), that licensees may convey the +work under this License, and how to view a copy of this License. If +the interface presents a list of user commands or options, such as a +menu, a prominent item in the list meets this criterion. + + 1. Source Code. + + The "source code" for a work means the preferred form of the work +for making modifications to it. "Object code" means any non-source +form of a work. + + A "Standard Interface" means an interface that either is an official +standard defined by a recognized standards body, or, in the case of +interfaces specified for a particular programming language, one that +is widely used among developers working in that language. + + The "System Libraries" of an executable work include anything, other +than the work as a whole, that (a) is included in the normal form of +packaging a Major Component, but which is not part of that Major +Component, and (b) serves only to enable use of the work with that +Major Component, or to implement a Standard Interface for which an +implementation is available to the public in source code form. A +"Major Component", in this context, means a major essential component +(kernel, window system, and so on) of the specific operating system +(if any) on which the executable work runs, or a compiler used to +produce the work, or an object code interpreter used to run it. + + The "Corresponding Source" for a work in object code form means all +the source code needed to generate, install, and (for an executable +work) run the object code and to modify the work, including scripts to +control those activities. However, it does not include the work's +System Libraries, or general-purpose tools or generally available free +programs which are used unmodified in performing those activities but +which are not part of the work. For example, Corresponding Source +includes interface definition files associated with source files for +the work, and the source code for shared libraries and dynamically +linked subprograms that the work is specifically designed to require, +such as by intimate data communication or control flow between those +subprograms and other parts of the work. + + The Corresponding Source need not include anything that users +can regenerate automatically from other parts of the Corresponding +Source. + + The Corresponding Source for a work in source code form is that +same work. + + 2. Basic Permissions. + + All rights granted under this License are granted for the term of +copyright on the Program, and are irrevocable provided the stated +conditions are met. This License explicitly affirms your unlimited +permission to run the unmodified Program. The output from running a +covered work is covered by this License only if the output, given its +content, constitutes a covered work. This License acknowledges your +rights of fair use or other equivalent, as provided by copyright law. + + You may make, run and propagate covered works that you do not +convey, without conditions so long as your license otherwise remains +in force. You may convey covered works to others for the sole purpose +of having them make modifications exclusively for you, or provide you +with facilities for running those works, provided that you comply with +the terms of this License in conveying all material for which you do +not control copyright. Those thus making or running the covered works +for you must do so exclusively on your behalf, under your direction +and control, on terms that prohibit them from making any copies of +your copyrighted material outside their relationship with you. + + Conveying under any other circumstances is permitted solely under +the conditions stated below. Sublicensing is not allowed; section 10 +makes it unnecessary. + + 3. Protecting Users' Legal Rights From Anti-Circumvention Law. + + No covered work shall be deemed part of an effective technological +measure under any applicable law fulfilling obligations under article +11 of the WIPO copyright treaty adopted on 20 December 1996, or +similar laws prohibiting or restricting circumvention of such +measures. + + When you convey a covered work, you waive any legal power to forbid +circumvention of technological measures to the extent such circumvention +is effected by exercising rights under this License with respect to +the covered work, and you disclaim any intention to limit operation or +modification of the work as a means of enforcing, against the work's +users, your or third parties' legal rights to forbid circumvention of +technological measures. + + 4. Conveying Verbatim Copies. + + You may convey verbatim copies of the Program's source code as you +receive it, in any medium, provided that you conspicuously and +appropriately publish on each copy an appropriate copyright notice; +keep intact all notices stating that this License and any +non-permissive terms added in accord with section 7 apply to the code; +keep intact all notices of the absence of any warranty; and give all +recipients a copy of this License along with the Program. + + You may charge any price or no price for each copy that you convey, +and you may offer support or warranty protection for a fee. + + 5. Conveying Modified Source Versions. + + You may convey a work based on the Program, or the modifications to +produce it from the Program, in the form of source code under the +terms of section 4, provided that you also meet all of these conditions: + + a) The work must carry prominent notices stating that you modified + it, and giving a relevant date. + + b) The work must carry prominent notices stating that it is + released under this License and any conditions added under section + 7. This requirement modifies the requirement in section 4 to + "keep intact all notices". + + c) You must license the entire work, as a whole, under this + License to anyone who comes into possession of a copy. This + License will therefore apply, along with any applicable section 7 + additional terms, to the whole of the work, and all its parts, + regardless of how they are packaged. This License gives no + permission to license the work in any other way, but it does not + invalidate such permission if you have separately received it. + + d) If the work has interactive user interfaces, each must display + Appropriate Legal Notices; however, if the Program has interactive + interfaces that do not display Appropriate Legal Notices, your + work need not make them do so. + + A compilation of a covered work with other separate and independent +works, which are not by their nature extensions of the covered work, +and which are not combined with it such as to form a larger program, +in or on a volume of a storage or distribution medium, is called an +"aggregate" if the compilation and its resulting copyright are not +used to limit the access or legal rights of the compilation's users +beyond what the individual works permit. Inclusion of a covered work +in an aggregate does not cause this License to apply to the other +parts of the aggregate. + + 6. Conveying Non-Source Forms. + + You may convey a covered work in object code form under the terms +of sections 4 and 5, provided that you also convey the +machine-readable Corresponding Source under the terms of this License, +in one of these ways: + + a) Convey the object code in, or embodied in, a physical product + (including a physical distribution medium), accompanied by the + Corresponding Source fixed on a durable physical medium + customarily used for software interchange. + + b) Convey the object code in, or embodied in, a physical product + (including a physical distribution medium), accompanied by a + written offer, valid for at least three years and valid for as + long as you offer spare parts or customer support for that product + model, to give anyone who possesses the object code either (1) a + copy of the Corresponding Source for all the software in the + product that is covered by this License, on a durable physical + medium customarily used for software interchange, for a price no + more than your reasonable cost of physically performing this + conveying of source, or (2) access to copy the + Corresponding Source from a network server at no charge. + + c) Convey individual copies of the object code with a copy of the + written offer to provide the Corresponding Source. This + alternative is allowed only occasionally and noncommercially, and + only if you received the object code with such an offer, in accord + with subsection 6b. + + d) Convey the object code by offering access from a designated + place (gratis or for a charge), and offer equivalent access to the + Corresponding Source in the same way through the same place at no + further charge. You need not require recipients to copy the + Corresponding Source along with the object code. If the place to + copy the object code is a network server, the Corresponding Source + may be on a different server (operated by you or a third party) + that supports equivalent copying facilities, provided you maintain + clear directions next to the object code saying where to find the + Corresponding Source. Regardless of what server hosts the + Corresponding Source, you remain obligated to ensure that it is + available for as long as needed to satisfy these requirements. + + e) Convey the object code using peer-to-peer transmission, provided + you inform other peers where the object code and Corresponding + Source of the work are being offered to the general public at no + charge under subsection 6d. + + A separable portion of the object code, whose source code is excluded +from the Corresponding Source as a System Library, need not be +included in conveying the object code work. + + A "User Product" is either (1) a "consumer product", which means any +tangible personal property which is normally used for personal, family, +or household purposes, or (2) anything designed or sold for incorporation +into a dwelling. In determining whether a product is a consumer product, +doubtful cases shall be resolved in favor of coverage. For a particular +product received by a particular user, "normally used" refers to a +typical or common use of that class of product, regardless of the status +of the particular user or of the way in which the particular user +actually uses, or expects or is expected to use, the product. A product +is a consumer product regardless of whether the product has substantial +commercial, industrial or non-consumer uses, unless such uses represent +the only significant mode of use of the product. + + "Installation Information" for a User Product means any methods, +procedures, authorization keys, or other information required to install +and execute modified versions of a covered work in that User Product from +a modified version of its Corresponding Source. The information must +suffice to ensure that the continued functioning of the modified object +code is in no case prevented or interfered with solely because +modification has been made. + + If you convey an object code work under this section in, or with, or +specifically for use in, a User Product, and the conveying occurs as +part of a transaction in which the right of possession and use of the +User Product is transferred to the recipient in perpetuity or for a +fixed term (regardless of how the transaction is characterized), the +Corresponding Source conveyed under this section must be accompanied +by the Installation Information. But this requirement does not apply +if neither you nor any third party retains the ability to install +modified object code on the User Product (for example, the work has +been installed in ROM). + + The requirement to provide Installation Information does not include a +requirement to continue to provide support service, warranty, or updates +for a work that has been modified or installed by the recipient, or for +the User Product in which it has been modified or installed. Access to a +network may be denied when the modification itself materially and +adversely affects the operation of the network or violates the rules and +protocols for communication across the network. + + Corresponding Source conveyed, and Installation Information provided, +in accord with this section must be in a format that is publicly +documented (and with an implementation available to the public in +source code form), and must require no special password or key for +unpacking, reading or copying. + + 7. Additional Terms. + + "Additional permissions" are terms that supplement the terms of this +License by making exceptions from one or more of its conditions. +Additional permissions that are applicable to the entire Program shall +be treated as though they were included in this License, to the extent +that they are valid under applicable law. If additional permissions +apply only to part of the Program, that part may be used separately +under those permissions, but the entire Program remains governed by +this License without regard to the additional permissions. + + When you convey a copy of a covered work, you may at your option +remove any additional permissions from that copy, or from any part of +it. (Additional permissions may be written to require their own +removal in certain cases when you modify the work.) You may place +additional permissions on material, added by you to a covered work, +for which you have or can give appropriate copyright permission. + + Notwithstanding any other provision of this License, for material you +add to a covered work, you may (if authorized by the copyright holders of +that material) supplement the terms of this License with terms: + + a) Disclaiming warranty or limiting liability differently from the + terms of sections 15 and 16 of this License; or + + b) Requiring preservation of specified reasonable legal notices or + author attributions in that material or in the Appropriate Legal + Notices displayed by works containing it; or + + c) Prohibiting misrepresentation of the origin of that material, or + requiring that modified versions of such material be marked in + reasonable ways as different from the original version; or + + d) Limiting the use for publicity purposes of names of licensors or + authors of the material; or + + e) Declining to grant rights under trademark law for use of some + trade names, trademarks, or service marks; or + + f) Requiring indemnification of licensors and authors of that + material by anyone who conveys the material (or modified versions of + it) with contractual assumptions of liability to the recipient, for + any liability that these contractual assumptions directly impose on + those licensors and authors. + + All other non-permissive additional terms are considered "further +restrictions" within the meaning of section 10. If the Program as you +received it, or any part of it, contains a notice stating that it is +governed by this License along with a term that is a further +restriction, you may remove that term. If a license document contains +a further restriction but permits relicensing or conveying under this +License, you may add to a covered work material governed by the terms +of that license document, provided that the further restriction does +not survive such relicensing or conveying. + + If you add terms to a covered work in accord with this section, you +must place, in the relevant source files, a statement of the +additional terms that apply to those files, or a notice indicating +where to find the applicable terms. + + Additional terms, permissive or non-permissive, may be stated in the +form of a separately written license, or stated as exceptions; +the above requirements apply either way. + + 8. Termination. + + You may not propagate or modify a covered work except as expressly +provided under this License. Any attempt otherwise to propagate or +modify it is void, and will automatically terminate your rights under +this License (including any patent licenses granted under the third +paragraph of section 11). + + However, if you cease all violation of this License, then your +license from a particular copyright holder is reinstated (a) +provisionally, unless and until the copyright holder explicitly and +finally terminates your license, and (b) permanently, if the copyright +holder fails to notify you of the violation by some reasonable means +prior to 60 days after the cessation. + + Moreover, your license from a particular copyright holder is +reinstated permanently if the copyright holder notifies you of the +violation by some reasonable means, this is the first time you have +received notice of violation of this License (for any work) from that +copyright holder, and you cure the violation prior to 30 days after +your receipt of the notice. + + Termination of your rights under this section does not terminate the +licenses of parties who have received copies or rights from you under +this License. If your rights have been terminated and not permanently +reinstated, you do not qualify to receive new licenses for the same +material under section 10. + + 9. Acceptance Not Required for Having Copies. + + You are not required to accept this License in order to receive or +run a copy of the Program. Ancillary propagation of a covered work +occurring solely as a consequence of using peer-to-peer transmission +to receive a copy likewise does not require acceptance. However, +nothing other than this License grants you permission to propagate or +modify any covered work. These actions infringe copyright if you do +not accept this License. Therefore, by modifying or propagating a +covered work, you indicate your acceptance of this License to do so. + + 10. Automatic Licensing of Downstream Recipients. + + Each time you convey a covered work, the recipient automatically +receives a license from the original licensors, to run, modify and +propagate that work, subject to this License. You are not responsible +for enforcing compliance by third parties with this License. + + An "entity transaction" is a transaction transferring control of an +organization, or substantially all assets of one, or subdividing an +organization, or merging organizations. If propagation of a covered +work results from an entity transaction, each party to that +transaction who receives a copy of the work also receives whatever +licenses to the work the party's predecessor in interest had or could +give under the previous paragraph, plus a right to possession of the +Corresponding Source of the work from the predecessor in interest, if +the predecessor has it or can get it with reasonable efforts. + + You may not impose any further restrictions on the exercise of the +rights granted or affirmed under this License. For example, you may +not impose a license fee, royalty, or other charge for exercise of +rights granted under this License, and you may not initiate litigation +(including a cross-claim or counterclaim in a lawsuit) alleging that +any patent claim is infringed by making, using, selling, offering for +sale, or importing the Program or any portion of it. + + 11. Patents. + + A "contributor" is a copyright holder who authorizes use under this +License of the Program or a work on which the Program is based. The +work thus licensed is called the contributor's "contributor version". + + A contributor's "essential patent claims" are all patent claims +owned or controlled by the contributor, whether already acquired or +hereafter acquired, that would be infringed by some manner, permitted +by this License, of making, using, or selling its contributor version, +but do not include claims that would be infringed only as a +consequence of further modification of the contributor version. For +purposes of this definition, "control" includes the right to grant +patent sublicenses in a manner consistent with the requirements of +this License. + + Each contributor grants you a non-exclusive, worldwide, royalty-free +patent license under the contributor's essential patent claims, to +make, use, sell, offer for sale, import and otherwise run, modify and +propagate the contents of its contributor version. + + In the following three paragraphs, a "patent license" is any express +agreement or commitment, however denominated, not to enforce a patent +(such as an express permission to practice a patent or covenant not to +sue for patent infringement). To "grant" such a patent license to a +party means to make such an agreement or commitment not to enforce a +patent against the party. + + If you convey a covered work, knowingly relying on a patent license, +and the Corresponding Source of the work is not available for anyone +to copy, free of charge and under the terms of this License, through a +publicly available network server or other readily accessible means, +then you must either (1) cause the Corresponding Source to be so +available, or (2) arrange to deprive yourself of the benefit of the +patent license for this particular work, or (3) arrange, in a manner +consistent with the requirements of this License, to extend the patent +license to downstream recipients. "Knowingly relying" means you have +actual knowledge that, but for the patent license, your conveying the +covered work in a country, or your recipient's use of the covered work +in a country, would infringe one or more identifiable patents in that +country that you have reason to believe are valid. + + If, pursuant to or in connection with a single transaction or +arrangement, you convey, or propagate by procuring conveyance of, a +covered work, and grant a patent license to some of the parties +receiving the covered work authorizing them to use, propagate, modify +or convey a specific copy of the covered work, then the patent license +you grant is automatically extended to all recipients of the covered +work and works based on it. + + A patent license is "discriminatory" if it does not include within +the scope of its coverage, prohibits the exercise of, or is +conditioned on the non-exercise of one or more of the rights that are +specifically granted under this License. You may not convey a covered +work if you are a party to an arrangement with a third party that is +in the business of distributing software, under which you make payment +to the third party based on the extent of your activity of conveying +the work, and under which the third party grants, to any of the +parties who would receive the covered work from you, a discriminatory +patent license (a) in connection with copies of the covered work +conveyed by you (or copies made from those copies), or (b) primarily +for and in connection with specific products or compilations that +contain the covered work, unless you entered into that arrangement, +or that patent license was granted, prior to 28 March 2007. + + Nothing in this License shall be construed as excluding or limiting +any implied license or other defenses to infringement that may +otherwise be available to you under applicable patent law. + + 12. No Surrender of Others' Freedom. + + If conditions are imposed on you (whether by court order, agreement or +otherwise) that contradict the conditions of this License, they do not +excuse you from the conditions of this License. If you cannot convey a +covered work so as to satisfy simultaneously your obligations under this +License and any other pertinent obligations, then as a consequence you may +not convey it at all. For example, if you agree to terms that obligate you +to collect a royalty for further conveying from those to whom you convey +the Program, the only way you could satisfy both those terms and this +License would be to refrain entirely from conveying the Program. + + 13. Use with the GNU Affero General Public License. + + Notwithstanding any other provision of this License, you have +permission to link or combine any covered work with a work licensed +under version 3 of the GNU Affero General Public License into a single +combined work, and to convey the resulting work. The terms of this +License will continue to apply to the part which is the covered work, +but the special requirements of the GNU Affero General Public License, +section 13, concerning interaction through a network will apply to the +combination as such. + + 14. Revised Versions of this License. + + The Free Software Foundation may publish revised and/or new versions of +the GNU General Public License from time to time. Such new versions will +be similar in spirit to the present version, but may differ in detail to +address new problems or concerns. + + Each version is given a distinguishing version number. If the +Program specifies that a certain numbered version of the GNU General +Public License "or any later version" applies to it, you have the +option of following the terms and conditions either of that numbered +version or of any later version published by the Free Software +Foundation. If the Program does not specify a version number of the +GNU General Public License, you may choose any version ever published +by the Free Software Foundation. + + If the Program specifies that a proxy can decide which future +versions of the GNU General Public License can be used, that proxy's +public statement of acceptance of a version permanently authorizes you +to choose that version for the Program. + + Later license versions may give you additional or different +permissions. However, no additional obligations are imposed on any +author or copyright holder as a result of your choosing to follow a +later version. + + 15. Disclaimer of Warranty. + + THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY +APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT +HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY +OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, +THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM +IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF +ALL NECESSARY SERVICING, REPAIR OR CORRECTION. + + 16. Limitation of Liability. + + IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING +WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS +THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY +GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE +USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF +DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD +PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), +EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF +SUCH DAMAGES. + + 17. Interpretation of Sections 15 and 16. + + If the disclaimer of warranty and limitation of liability provided +above cannot be given local legal effect according to their terms, +reviewing courts shall apply local law that most closely approximates +an absolute waiver of all civil liability in connection with the +Program, unless a warranty or assumption of liability accompanies a +copy of the Program in return for a fee. + + END OF TERMS AND CONDITIONS + + How to Apply These Terms to Your New Programs + + If you develop a new program, and you want it to be of the greatest +possible use to the public, the best way to achieve this is to make it +free software which everyone can redistribute and change under these terms. + + To do so, attach the following notices to the program. It is safest +to attach them to the start of each source file to most effectively +state the exclusion of warranty; and each file should have at least +the "copyright" line and a pointer to where the full notice is found. + + + Copyright (C) + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . + +Also add information on how to contact you by electronic and paper mail. + + If the program does terminal interaction, make it output a short +notice like this when it starts in an interactive mode: + + Copyright (C) + This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'. + This is free software, and you are welcome to redistribute it + under certain conditions; type `show c' for details. + +The hypothetical commands `show w' and `show c' should show the appropriate +parts of the General Public License. Of course, your program's commands +might be different; for a GUI interface, you would use an "about box". + + You should also get your employer (if you work as a programmer) or school, +if any, to sign a "copyright disclaimer" for the program, if necessary. +For more information on this, and how to apply and follow the GNU GPL, see +. + + The GNU General Public License does not permit incorporating your program +into proprietary programs. If your program is a subroutine library, you +may consider it more useful to permit linking proprietary applications with +the library. If this is what you want to do, use the GNU Lesser General +Public License instead of this License. But first, please read +. GNU GENERAL PUBLIC LICENSE + Version 3, 29 June 2007 + + Copyright (C) 2007 Free Software Foundation, Inc. + Everyone is permitted to copy and distribute verbatim copies + of this license document, but changing it is not allowed. + + Preamble + + The GNU General Public License is a free, copyleft license for +software and other kinds of works. + + The licenses for most software and other practical works are designed +to take away your freedom to share and change the works. By contrast, +the GNU General Public License is intended to guarantee your freedom to +share and change all versions of a program--to make sure it remains free +software for all its users. We, the Free Software Foundation, use the +GNU General Public License for most of our software; it applies also to +any other work released this way by its authors. You can apply it to +your programs, too. + + When we speak of free software, we are referring to freedom, not +price. Our General Public Licenses are designed to make sure that you +have the freedom to distribute copies of free software (and charge for +them if you wish), that you receive source code or can get it if you +want it, that you can change the software or use pieces of it in new +free programs, and that you know you can do these things. + + To protect your rights, we need to prevent others from denying you +these rights or asking you to surrender the rights. Therefore, you have +certain responsibilities if you distribute copies of the software, or if +you modify it: responsibilities to respect the freedom of others. + + For example, if you distribute copies of such a program, whether +gratis or for a fee, you must pass on to the recipients the same +freedoms that you received. You must make sure that they, too, receive +or can get the source code. And you must show them these terms so they +know their rights. + + Developers that use the GNU GPL protect your rights with two steps: +(1) assert copyright on the software, and (2) offer you this License +giving you legal permission to copy, distribute and/or modify it. + + For the developers' and authors' protection, the GPL clearly explains +that there is no warranty for this free software. For both users' and +authors' sake, the GPL requires that modified versions be marked as +changed, so that their problems will not be attributed erroneously to +authors of previous versions. + + Some devices are designed to deny users access to install or run +modified versions of the software inside them, although the manufacturer +can do so. This is fundamentally incompatible with the aim of +protecting users' freedom to change the software. The systematic +pattern of such abuse occurs in the area of products for individuals to +use, which is precisely where it is most unacceptable. Therefore, we +have designed this version of the GPL to prohibit the practice for those +products. If such problems arise substantially in other domains, we +stand ready to extend this provision to those domains in future versions +of the GPL, as needed to protect the freedom of users. + + Finally, every program is threatened constantly by software patents. +States should not allow patents to restrict development and use of +software on general-purpose computers, but in those that do, we wish to +avoid the special danger that patents applied to a free program could +make it effectively proprietary. To prevent this, the GPL assures that +patents cannot be used to render the program non-free. + + The precise terms and conditions for copying, distribution and +modification follow. + + TERMS AND CONDITIONS + + 0. Definitions. + + "This License" refers to version 3 of the GNU General Public License. + + "Copyright" also means copyright-like laws that apply to other kinds of +works, such as semiconductor masks. + + "The Program" refers to any copyrightable work licensed under this +License. Each licensee is addressed as "you". "Licensees" and +"recipients" may be individuals or organizations. + + To "modify" a work means to copy from or adapt all or part of the work +in a fashion requiring copyright permission, other than the making of an +exact copy. The resulting work is called a "modified version" of the +earlier work or a work "based on" the earlier work. + + A "covered work" means either the unmodified Program or a work based +on the Program. + + To "propagate" a work means to do anything with it that, without +permission, would make you directly or secondarily liable for +infringement under applicable copyright law, except executing it on a +computer or modifying a private copy. Propagation includes copying, +distribution (with or without modification), making available to the +public, and in some countries other activities as well. + + To "convey" a work means any kind of propagation that enables other +parties to make or receive copies. Mere interaction with a user through +a computer network, with no transfer of a copy, is not conveying. + + An interactive user interface displays "Appropriate Legal Notices" +to the extent that it includes a convenient and prominently visible +feature that (1) displays an appropriate copyright notice, and (2) +tells the user that there is no warranty for the work (except to the +extent that warranties are provided), that licensees may convey the +work under this License, and how to view a copy of this License. If +the interface presents a list of user commands or options, such as a +menu, a prominent item in the list meets this criterion. + + 1. Source Code. + + The "source code" for a work means the preferred form of the work +for making modifications to it. "Object code" means any non-source +form of a work. + + A "Standard Interface" means an interface that either is an official +standard defined by a recognized standards body, or, in the case of +interfaces specified for a particular programming language, one that +is widely used among developers working in that language. + + The "System Libraries" of an executable work include anything, other +than the work as a whole, that (a) is included in the normal form of +packaging a Major Component, but which is not part of that Major +Component, and (b) serves only to enable use of the work with that +Major Component, or to implement a Standard Interface for which an +implementation is available to the public in source code form. A +"Major Component", in this context, means a major essential component +(kernel, window system, and so on) of the specific operating system +(if any) on which the executable work runs, or a compiler used to +produce the work, or an object code interpreter used to run it. + + The "Corresponding Source" for a work in object code form means all +the source code needed to generate, install, and (for an executable +work) run the object code and to modify the work, including scripts to +control those activities. However, it does not include the work's +System Libraries, or general-purpose tools or generally available free +programs which are used unmodified in performing those activities but +which are not part of the work. For example, Corresponding Source +includes interface definition files associated with source files for +the work, and the source code for shared libraries and dynamically +linked subprograms that the work is specifically designed to require, +such as by intimate data communication or control flow between those +subprograms and other parts of the work. + + The Corresponding Source need not include anything that users +can regenerate automatically from other parts of the Corresponding +Source. + + The Corresponding Source for a work in source code form is that +same work. + + 2. Basic Permissions. + + All rights granted under this License are granted for the term of +copyright on the Program, and are irrevocable provided the stated +conditions are met. This License explicitly affirms your unlimited +permission to run the unmodified Program. The output from running a +covered work is covered by this License only if the output, given its +content, constitutes a covered work. This License acknowledges your +rights of fair use or other equivalent, as provided by copyright law. + + You may make, run and propagate covered works that you do not +convey, without conditions so long as your license otherwise remains +in force. You may convey covered works to others for the sole purpose +of having them make modifications exclusively for you, or provide you +with facilities for running those works, provided that you comply with +the terms of this License in conveying all material for which you do +not control copyright. Those thus making or running the covered works +for you must do so exclusively on your behalf, under your direction +and control, on terms that prohibit them from making any copies of +your copyrighted material outside their relationship with you. + + Conveying under any other circumstances is permitted solely under +the conditions stated below. Sublicensing is not allowed; section 10 +makes it unnecessary. + + 3. Protecting Users' Legal Rights From Anti-Circumvention Law. + + No covered work shall be deemed part of an effective technological +measure under any applicable law fulfilling obligations under article +11 of the WIPO copyright treaty adopted on 20 December 1996, or +similar laws prohibiting or restricting circumvention of such +measures. + + When you convey a covered work, you waive any legal power to forbid +circumvention of technological measures to the extent such circumvention +is effected by exercising rights under this License with respect to +the covered work, and you disclaim any intention to limit operation or +modification of the work as a means of enforcing, against the work's +users, your or third parties' legal rights to forbid circumvention of +technological measures. + + 4. Conveying Verbatim Copies. + + You may convey verbatim copies of the Program's source code as you +receive it, in any medium, provided that you conspicuously and +appropriately publish on each copy an appropriate copyright notice; +keep intact all notices stating that this License and any +non-permissive terms added in accord with section 7 apply to the code; +keep intact all notices of the absence of any warranty; and give all +recipients a copy of this License along with the Program. + + You may charge any price or no price for each copy that you convey, +and you may offer support or warranty protection for a fee. + + 5. Conveying Modified Source Versions. + + You may convey a work based on the Program, or the modifications to +produce it from the Program, in the form of source code under the +terms of section 4, provided that you also meet all of these conditions: + + a) The work must carry prominent notices stating that you modified + it, and giving a relevant date. + + b) The work must carry prominent notices stating that it is + released under this License and any conditions added under section + 7. This requirement modifies the requirement in section 4 to + "keep intact all notices". + + c) You must license the entire work, as a whole, under this + License to anyone who comes into possession of a copy. This + License will therefore apply, along with any applicable section 7 + additional terms, to the whole of the work, and all its parts, + regardless of how they are packaged. This License gives no + permission to license the work in any other way, but it does not + invalidate such permission if you have separately received it. + + d) If the work has interactive user interfaces, each must display + Appropriate Legal Notices; however, if the Program has interactive + interfaces that do not display Appropriate Legal Notices, your + work need not make them do so. + + A compilation of a covered work with other separate and independent +works, which are not by their nature extensions of the covered work, +and which are not combined with it such as to form a larger program, +in or on a volume of a storage or distribution medium, is called an +"aggregate" if the compilation and its resulting copyright are not +used to limit the access or legal rights of the compilation's users +beyond what the individual works permit. Inclusion of a covered work +in an aggregate does not cause this License to apply to the other +parts of the aggregate. + + 6. Conveying Non-Source Forms. + + You may convey a covered work in object code form under the terms +of sections 4 and 5, provided that you also convey the +machine-readable Corresponding Source under the terms of this License, +in one of these ways: + + a) Convey the object code in, or embodied in, a physical product + (including a physical distribution medium), accompanied by the + Corresponding Source fixed on a durable physical medium + customarily used for software interchange. + + b) Convey the object code in, or embodied in, a physical product + (including a physical distribution medium), accompanied by a + written offer, valid for at least three years and valid for as + long as you offer spare parts or customer support for that product + model, to give anyone who possesses the object code either (1) a + copy of the Corresponding Source for all the software in the + product that is covered by this License, on a durable physical + medium customarily used for software interchange, for a price no + more than your reasonable cost of physically performing this + conveying of source, or (2) access to copy the + Corresponding Source from a network server at no charge. + + c) Convey individual copies of the object code with a copy of the + written offer to provide the Corresponding Source. This + alternative is allowed only occasionally and noncommercially, and + only if you received the object code with such an offer, in accord + with subsection 6b. + + d) Convey the object code by offering access from a designated + place (gratis or for a charge), and offer equivalent access to the + Corresponding Source in the same way through the same place at no + further charge. You need not require recipients to copy the + Corresponding Source along with the object code. If the place to + copy the object code is a network server, the Corresponding Source + may be on a different server (operated by you or a third party) + that supports equivalent copying facilities, provided you maintain + clear directions next to the object code saying where to find the + Corresponding Source. Regardless of what server hosts the + Corresponding Source, you remain obligated to ensure that it is + available for as long as needed to satisfy these requirements. + + e) Convey the object code using peer-to-peer transmission, provided + you inform other peers where the object code and Corresponding + Source of the work are being offered to the general public at no + charge under subsection 6d. + + A separable portion of the object code, whose source code is excluded +from the Corresponding Source as a System Library, need not be +included in conveying the object code work. + + A "User Product" is either (1) a "consumer product", which means any +tangible personal property which is normally used for personal, family, +or household purposes, or (2) anything designed or sold for incorporation +into a dwelling. In determining whether a product is a consumer product, +doubtful cases shall be resolved in favor of coverage. For a particular +product received by a particular user, "normally used" refers to a +typical or common use of that class of product, regardless of the status +of the particular user or of the way in which the particular user +actually uses, or expects or is expected to use, the product. A product +is a consumer product regardless of whether the product has substantial +commercial, industrial or non-consumer uses, unless such uses represent +the only significant mode of use of the product. + + "Installation Information" for a User Product means any methods, +procedures, authorization keys, or other information required to install +and execute modified versions of a covered work in that User Product from +a modified version of its Corresponding Source. The information must +suffice to ensure that the continued functioning of the modified object +code is in no case prevented or interfered with solely because +modification has been made. + + If you convey an object code work under this section in, or with, or +specifically for use in, a User Product, and the conveying occurs as +part of a transaction in which the right of possession and use of the +User Product is transferred to the recipient in perpetuity or for a +fixed term (regardless of how the transaction is characterized), the +Corresponding Source conveyed under this section must be accompanied +by the Installation Information. But this requirement does not apply +if neither you nor any third party retains the ability to install +modified object code on the User Product (for example, the work has +been installed in ROM). + + The requirement to provide Installation Information does not include a +requirement to continue to provide support service, warranty, or updates +for a work that has been modified or installed by the recipient, or for +the User Product in which it has been modified or installed. Access to a +network may be denied when the modification itself materially and +adversely affects the operation of the network or violates the rules and +protocols for communication across the network. + + Corresponding Source conveyed, and Installation Information provided, +in accord with this section must be in a format that is publicly +documented (and with an implementation available to the public in +source code form), and must require no special password or key for +unpacking, reading or copying. + + 7. Additional Terms. + + "Additional permissions" are terms that supplement the terms of this +License by making exceptions from one or more of its conditions. +Additional permissions that are applicable to the entire Program shall +be treated as though they were included in this License, to the extent +that they are valid under applicable law. If additional permissions +apply only to part of the Program, that part may be used separately +under those permissions, but the entire Program remains governed by +this License without regard to the additional permissions. + + When you convey a copy of a covered work, you may at your option +remove any additional permissions from that copy, or from any part of +it. (Additional permissions may be written to require their own +removal in certain cases when you modify the work.) You may place +additional permissions on material, added by you to a covered work, +for which you have or can give appropriate copyright permission. + + Notwithstanding any other provision of this License, for material you +add to a covered work, you may (if authorized by the copyright holders of +that material) supplement the terms of this License with terms: + + a) Disclaiming warranty or limiting liability differently from the + terms of sections 15 and 16 of this License; or + + b) Requiring preservation of specified reasonable legal notices or + author attributions in that material or in the Appropriate Legal + Notices displayed by works containing it; or + + c) Prohibiting misrepresentation of the origin of that material, or + requiring that modified versions of such material be marked in + reasonable ways as different from the original version; or + + d) Limiting the use for publicity purposes of names of licensors or + authors of the material; or + + e) Declining to grant rights under trademark law for use of some + trade names, trademarks, or service marks; or + + f) Requiring indemnification of licensors and authors of that + material by anyone who conveys the material (or modified versions of + it) with contractual assumptions of liability to the recipient, for + any liability that these contractual assumptions directly impose on + those licensors and authors. + + All other non-permissive additional terms are considered "further +restrictions" within the meaning of section 10. If the Program as you +received it, or any part of it, contains a notice stating that it is +governed by this License along with a term that is a further +restriction, you may remove that term. If a license document contains +a further restriction but permits relicensing or conveying under this +License, you may add to a covered work material governed by the terms +of that license document, provided that the further restriction does +not survive such relicensing or conveying. + + If you add terms to a covered work in accord with this section, you +must place, in the relevant source files, a statement of the +additional terms that apply to those files, or a notice indicating +where to find the applicable terms. + + Additional terms, permissive or non-permissive, may be stated in the +form of a separately written license, or stated as exceptions; +the above requirements apply either way. + + 8. Termination. + + You may not propagate or modify a covered work except as expressly +provided under this License. Any attempt otherwise to propagate or +modify it is void, and will automatically terminate your rights under +this License (including any patent licenses granted under the third +paragraph of section 11). + + However, if you cease all violation of this License, then your +license from a particular copyright holder is reinstated (a) +provisionally, unless and until the copyright holder explicitly and +finally terminates your license, and (b) permanently, if the copyright +holder fails to notify you of the violation by some reasonable means +prior to 60 days after the cessation. + + Moreover, your license from a particular copyright holder is +reinstated permanently if the copyright holder notifies you of the +violation by some reasonable means, this is the first time you have +received notice of violation of this License (for any work) from that +copyright holder, and you cure the violation prior to 30 days after +your receipt of the notice. + + Termination of your rights under this section does not terminate the +licenses of parties who have received copies or rights from you under +this License. If your rights have been terminated and not permanently +reinstated, you do not qualify to receive new licenses for the same +material under section 10. + + 9. Acceptance Not Required for Having Copies. + + You are not required to accept this License in order to receive or +run a copy of the Program. Ancillary propagation of a covered work +occurring solely as a consequence of using peer-to-peer transmission +to receive a copy likewise does not require acceptance. However, +nothing other than this License grants you permission to propagate or +modify any covered work. These actions infringe copyright if you do +not accept this License. Therefore, by modifying or propagating a +covered work, you indicate your acceptance of this License to do so. + + 10. Automatic Licensing of Downstream Recipients. + + Each time you convey a covered work, the recipient automatically +receives a license from the original licensors, to run, modify and +propagate that work, subject to this License. You are not responsible +for enforcing compliance by third parties with this License. + + An "entity transaction" is a transaction transferring control of an +organization, or substantially all assets of one, or subdividing an +organization, or merging organizations. If propagation of a covered +work results from an entity transaction, each party to that +transaction who receives a copy of the work also receives whatever +licenses to the work the party's predecessor in interest had or could +give under the previous paragraph, plus a right to possession of the +Corresponding Source of the work from the predecessor in interest, if +the predecessor has it or can get it with reasonable efforts. + + You may not impose any further restrictions on the exercise of the +rights granted or affirmed under this License. For example, you may +not impose a license fee, royalty, or other charge for exercise of +rights granted under this License, and you may not initiate litigation +(including a cross-claim or counterclaim in a lawsuit) alleging that +any patent claim is infringed by making, using, selling, offering for +sale, or importing the Program or any portion of it. + + 11. Patents. + + A "contributor" is a copyright holder who authorizes use under this +License of the Program or a work on which the Program is based. The +work thus licensed is called the contributor's "contributor version". + + A contributor's "essential patent claims" are all patent claims +owned or controlled by the contributor, whether already acquired or +hereafter acquired, that would be infringed by some manner, permitted +by this License, of making, using, or selling its contributor version, +but do not include claims that would be infringed only as a +consequence of further modification of the contributor version. For +purposes of this definition, "control" includes the right to grant +patent sublicenses in a manner consistent with the requirements of +this License. + + Each contributor grants you a non-exclusive, worldwide, royalty-free +patent license under the contributor's essential patent claims, to +make, use, sell, offer for sale, import and otherwise run, modify and +propagate the contents of its contributor version. + + In the following three paragraphs, a "patent license" is any express +agreement or commitment, however denominated, not to enforce a patent +(such as an express permission to practice a patent or covenant not to +sue for patent infringement). To "grant" such a patent license to a +party means to make such an agreement or commitment not to enforce a +patent against the party. + + If you convey a covered work, knowingly relying on a patent license, +and the Corresponding Source of the work is not available for anyone +to copy, free of charge and under the terms of this License, through a +publicly available network server or other readily accessible means, +then you must either (1) cause the Corresponding Source to be so +available, or (2) arrange to deprive yourself of the benefit of the +patent license for this particular work, or (3) arrange, in a manner +consistent with the requirements of this License, to extend the patent +license to downstream recipients. "Knowingly relying" means you have +actual knowledge that, but for the patent license, your conveying the +covered work in a country, or your recipient's use of the covered work +in a country, would infringe one or more identifiable patents in that +country that you have reason to believe are valid. + + If, pursuant to or in connection with a single transaction or +arrangement, you convey, or propagate by procuring conveyance of, a +covered work, and grant a patent license to some of the parties +receiving the covered work authorizing them to use, propagate, modify +or convey a specific copy of the covered work, then the patent license +you grant is automatically extended to all recipients of the covered +work and works based on it. + + A patent license is "discriminatory" if it does not include within +the scope of its coverage, prohibits the exercise of, or is +conditioned on the non-exercise of one or more of the rights that are +specifically granted under this License. You may not convey a covered +work if you are a party to an arrangement with a third party that is +in the business of distributing software, under which you make payment +to the third party based on the extent of your activity of conveying +the work, and under which the third party grants, to any of the +parties who would receive the covered work from you, a discriminatory +patent license (a) in connection with copies of the covered work +conveyed by you (or copies made from those copies), or (b) primarily +for and in connection with specific products or compilations that +contain the covered work, unless you entered into that arrangement, +or that patent license was granted, prior to 28 March 2007. + + Nothing in this License shall be construed as excluding or limiting +any implied license or other defenses to infringement that may +otherwise be available to you under applicable patent law. + + 12. No Surrender of Others' Freedom. + + If conditions are imposed on you (whether by court order, agreement or +otherwise) that contradict the conditions of this License, they do not +excuse you from the conditions of this License. If you cannot convey a +covered work so as to satisfy simultaneously your obligations under this +License and any other pertinent obligations, then as a consequence you may +not convey it at all. For example, if you agree to terms that obligate you +to collect a royalty for further conveying from those to whom you convey +the Program, the only way you could satisfy both those terms and this +License would be to refrain entirely from conveying the Program. + + 13. Use with the GNU Affero General Public License. + + Notwithstanding any other provision of this License, you have +permission to link or combine any covered work with a work licensed +under version 3 of the GNU Affero General Public License into a single +combined work, and to convey the resulting work. The terms of this +License will continue to apply to the part which is the covered work, +but the special requirements of the GNU Affero General Public License, +section 13, concerning interaction through a network will apply to the +combination as such. + + 14. Revised Versions of this License. + + The Free Software Foundation may publish revised and/or new versions of +the GNU General Public License from time to time. Such new versions will +be similar in spirit to the present version, but may differ in detail to +address new problems or concerns. + + Each version is given a distinguishing version number. If the +Program specifies that a certain numbered version of the GNU General +Public License "or any later version" applies to it, you have the +option of following the terms and conditions either of that numbered +version or of any later version published by the Free Software +Foundation. If the Program does not specify a version number of the +GNU General Public License, you may choose any version ever published +by the Free Software Foundation. + + If the Program specifies that a proxy can decide which future +versions of the GNU General Public License can be used, that proxy's +public statement of acceptance of a version permanently authorizes you +to choose that version for the Program. + + Later license versions may give you additional or different +permissions. However, no additional obligations are imposed on any +author or copyright holder as a result of your choosing to follow a +later version. + + 15. Disclaimer of Warranty. + + THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY +APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT +HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY +OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, +THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM +IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF +ALL NECESSARY SERVICING, REPAIR OR CORRECTION. + + 16. Limitation of Liability. + + IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING +WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS +THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY +GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE +USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF +DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD +PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), +EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF +SUCH DAMAGES. + + 17. Interpretation of Sections 15 and 16. + + If the disclaimer of warranty and limitation of liability provided +above cannot be given local legal effect according to their terms, +reviewing courts shall apply local law that most closely approximates +an absolute waiver of all civil liability in connection with the +Program, unless a warranty or assumption of liability accompanies a +copy of the Program in return for a fee. + + END OF TERMS AND CONDITIONS + + How to Apply These Terms to Your New Programs + + If you develop a new program, and you want it to be of the greatest +possible use to the public, the best way to achieve this is to make it +free software which everyone can redistribute and change under these terms. + + To do so, attach the following notices to the program. It is safest +to attach them to the start of each source file to most effectively +state the exclusion of warranty; and each file should have at least +the "copyright" line and a pointer to where the full notice is found. + + + Copyright (C) + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . + +Also add information on how to contact you by electronic and paper mail. + + If the program does terminal interaction, make it output a short +notice like this when it starts in an interactive mode: + + Copyright (C) + This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'. + This is free software, and you are welcome to redistribute it + under certain conditions; type `show c' for details. + +The hypothetical commands `show w' and `show c' should show the appropriate +parts of the General Public License. Of course, your program's commands +might be different; for a GUI interface, you would use an "about box". + + You should also get your employer (if you work as a programmer) or school, +if any, to sign a "copyright disclaimer" for the program, if necessary. +For more information on this, and how to apply and follow the GNU GPL, see +. + + The GNU General Public License does not permit incorporating your program +into proprietary programs. If your program is a subroutine library, you +may consider it more useful to permit linking proprietary applications with +the library. If this is what you want to do, use the GNU Lesser General +Public License instead of this License. But first, please read +. diff --git a/gulagcleaner_wasm/src/lib.rs b/gulagcleaner_wasm/src/lib.rs index 71deef6..9230183 100644 --- a/gulagcleaner_wasm/src/lib.rs +++ b/gulagcleaner_wasm/src/lib.rs @@ -1,7 +1,7 @@ use wasm_bindgen::prelude::*; -use gulagcleaner; +use gulagcleaner_rs; #[wasm_bindgen] -pub fn clean_pdf(a: usize, b: usize) -> String { - gulagcleaner::clean_pdf(a, b) +pub fn clean_pdf(data: Vec,force_naive: u8) -> Vec { + gulagcleaner_rs::clean_pdf(data, force_naive) } \ No newline at end of file From 1eaefa6c070f6e22144c188f7fb679a8f02bdd11 Mon Sep 17 00:00:00 2001 From: YM162 Date: Sat, 23 Dec 2023 03:50:23 +0100 Subject: [PATCH 19/27] Added/Removed some comments. --- gulagcleaner_python/Cargo.toml | 1 - gulagcleaner_python/pyproject.toml | 2 +- gulagcleaner_python/python/gulagcleaner/clean.py | 5 ++++- gulagcleaner_python/rust/lib.rs | 2 -- gulagcleaner_rs/Cargo.toml | 2 -- gulagcleaner_rs/src/lib.rs | 3 ++- gulagcleaner_rs/src/method.rs | 2 ++ gulagcleaner_rs/src/page_type.rs | 2 ++ gulagcleaner_wasm/Cargo.toml | 3 --- 9 files changed, 11 insertions(+), 11 deletions(-) diff --git a/gulagcleaner_python/Cargo.toml b/gulagcleaner_python/Cargo.toml index 29fec1d..d1fce8b 100644 --- a/gulagcleaner_python/Cargo.toml +++ b/gulagcleaner_python/Cargo.toml @@ -10,7 +10,6 @@ repository = "https://github.com/YM162/gulag-cleaner-cli.git" license-file = "../LICENSE" keywords = ["wuolah", "pdf", "ads", "advertisments", "cleaner", "gulagcleaner"] -# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html [lib] name = "gulagcleaner_python" crate-type = ["cdylib"] diff --git a/gulagcleaner_python/pyproject.toml b/gulagcleaner_python/pyproject.toml index f63dda3..45f7a51 100644 --- a/gulagcleaner_python/pyproject.toml +++ b/gulagcleaner_python/pyproject.toml @@ -33,4 +33,4 @@ find = { where = ["python"] } [[tool.setuptools-rust.ext-modules]] # Private Rust extension module to be nested into Python package -target = "gulagcleaner._lib" # The last part of the name (e.g. "_lib") has to match lib.name in Cargo.toml, \ No newline at end of file +target = "gulagcleaner._lib" \ No newline at end of file diff --git a/gulagcleaner_python/python/gulagcleaner/clean.py b/gulagcleaner_python/python/gulagcleaner/clean.py index 5c3967f..5bde636 100644 --- a/gulagcleaner_python/python/gulagcleaner/clean.py +++ b/gulagcleaner_python/python/gulagcleaner/clean.py @@ -27,4 +27,7 @@ def clean_pdf_path(pdf_path, output_path, force_naive): "method": method, "error": ""} except Exception as e: - return {"success": False, "return_path": "","method":"", "error": str(e)} \ No newline at end of file + return {"success": False, "return_path": "","method":"", "error": str(e)} + +# I would like to expose the clean_pdf function as a "clean_pdf_bytes(bytes)" function that already removes the trailing method byte and returns the cleaned bytes and the method. +# Working on it. \ No newline at end of file diff --git a/gulagcleaner_python/rust/lib.rs b/gulagcleaner_python/rust/lib.rs index 73d367f..88713b7 100644 --- a/gulagcleaner_python/rust/lib.rs +++ b/gulagcleaner_python/rust/lib.rs @@ -1,12 +1,10 @@ use pyo3::prelude::*; -/// I only need to replace the sum_as_string function with the clean_pdf function, and the arguments to be u8 vectors. Maybe I need to change some types here to pure rust. #[pyfunction] pub fn clean_pdf(data: Vec,force_naive: u8) -> PyResult> { Ok(gulagcleaner_rs::clean_pdf(data, force_naive)) } -/// I only need to replace the sum_as_string function with the clean_pdf function #[pymodule] fn _lib(_py: Python, m: &PyModule) -> PyResult<()> { m.add_function(wrap_pyfunction!(clean_pdf, m)?)?; diff --git a/gulagcleaner_rs/Cargo.toml b/gulagcleaner_rs/Cargo.toml index d2c318f..738908a 100644 --- a/gulagcleaner_rs/Cargo.toml +++ b/gulagcleaner_rs/Cargo.toml @@ -10,8 +10,6 @@ repository = "https://github.com/YM162/gulag-cleaner-cli.git" license-file = "../LICENSE" keywords = ["wuolah", "pdf", "ads", "advertisments", "cleaner", "gulagcleaner"] -# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html - [lib] name = "gulagcleaner_rs" diff --git a/gulagcleaner_rs/src/lib.rs b/gulagcleaner_rs/src/lib.rs index cd02e2a..cc0876f 100644 --- a/gulagcleaner_rs/src/lib.rs +++ b/gulagcleaner_rs/src/lib.rs @@ -1,4 +1,5 @@ -//Here I should place my gulagcleaner-rust functions, and then call clean_pdf from python_binder.rs +//WARNING: I need to add comments to all of the files in this folder. I will do it ASAP. I'm sorry for the inconvenience. + pub mod method; diff --git a/gulagcleaner_rs/src/method.rs b/gulagcleaner_rs/src/method.rs index 588e090..00880b4 100644 --- a/gulagcleaner_rs/src/method.rs +++ b/gulagcleaner_rs/src/method.rs @@ -1,3 +1,5 @@ +//WARNING: I need to add comments to all of the files in this folder. I will do it ASAP. I'm sorry for the inconvenience. + use std::collections::HashSet; use lopdf::Document; diff --git a/gulagcleaner_rs/src/page_type.rs b/gulagcleaner_rs/src/page_type.rs index 15a2908..485dd46 100644 --- a/gulagcleaner_rs/src/page_type.rs +++ b/gulagcleaner_rs/src/page_type.rs @@ -1,3 +1,5 @@ +//WARNING: I need to add comments to all of the files in this folder. I will do it ASAP. I'm sorry for the inconvenience. + use std::{error::Error, collections::HashSet}; use lopdf::{Document, ObjectId}; diff --git a/gulagcleaner_wasm/Cargo.toml b/gulagcleaner_wasm/Cargo.toml index 4267aa3..3f9875a 100644 --- a/gulagcleaner_wasm/Cargo.toml +++ b/gulagcleaner_wasm/Cargo.toml @@ -10,9 +10,6 @@ repository = "https://github.com/YM162/gulag-cleaner-cli.git" license-file = "../LICENSE" keywords = ["wuolah", "pdf", "ads", "advertisments", "cleaner", "gulagcleaner"] - -# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html - [lib] crate-type = ["cdylib"] From 86299072c8f177e6ae40622cc369a4d0c7e6751d Mon Sep 17 00:00:00 2001 From: YM162 Date: Sun, 24 Dec 2023 04:35:36 +0100 Subject: [PATCH 20/27] Added npm registry --- .github/workflows/wasm_publish.yml | 41 +++++++++++++++++++++--------- gulagcleaner_python/pyproject.toml | 2 +- 2 files changed, 30 insertions(+), 13 deletions(-) diff --git a/.github/workflows/wasm_publish.yml b/.github/workflows/wasm_publish.yml index 02e251c..42d50e8 100644 --- a/.github/workflows/wasm_publish.yml +++ b/.github/workflows/wasm_publish.yml @@ -3,7 +3,7 @@ name: Build WASM and publish in the WASM_build branch on: push: branches: - - main + - rust_bindings jobs: build: @@ -11,22 +11,39 @@ jobs: name: Build and Push steps: - name: git-checkout - uses: actions/checkout@v2 + uses: actions/checkout@v4 - name: install wasm-pack run: curl https://rustwasm.github.io/wasm-pack/installer/init.sh -sSf | sh - name: build wasm - run: wasm-pack build gulagcleaner_wasm --target web --release --no-typescript -d WASM_build + run: wasm-pack build gulagcleaner_wasm --target web --release -d WASM_build - - name: remove gitignore - run: rm gulagcleaner_wasm/WASM_build/.gitignore + # - name: remove gitignore + # run: rm gulagcleaner_wasm/WASM_build/.gitignore - - name: push to the WASM_build branch - uses: s0/git-publish-subdir-action@develop + # - name: push to the WASM_build branch + # uses: s0/git-publish-subdir-action@develop + # env: + # REPO: self + # BRANCH: WASM_build # The branch name where you want to push the assets + # FOLDER: gulagcleaner_wasm/WASM_build # The directory where your assets are generated + # GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # GitHub will automatically add this - you don't need to bother getting a token + # MESSAGE: "Build: ({sha}) {msg}" # The commit message + + - name: setup node + working-directory: ./gulagcleaner_wasm/WASM_build + uses: actions/setup-node@v3 + with: + node-version: '20.x' + registry-url: 'https://registry.npmjs.org' + + - name: run ci + working-directory: ./gulagcleaner_wasm/WASM_build + run: npm ci + + - name: publish to npm + working-directory: ./gulagcleaner_wasm/WASM_build + run: npm publish env: - REPO: self - BRANCH: WASM_build # The branch name where you want to push the assets - FOLDER: gulagcleaner_wasm/WASM_build # The directory where your assets are generated - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # GitHub will automatically add this - you don't need to bother getting a token - MESSAGE: "Build: ({sha}) {msg}" # The commit message \ No newline at end of file + NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} \ No newline at end of file diff --git a/gulagcleaner_python/pyproject.toml b/gulagcleaner_python/pyproject.toml index 45f7a51..297d3e7 100644 --- a/gulagcleaner_python/pyproject.toml +++ b/gulagcleaner_python/pyproject.toml @@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta" [project] name = "gulagcleaner" -version = "0.0.1" +version = "0.10.0" description = "Ad removal tool for PDFs." authors = [ {name = "YM162", email = "david.fontaneda16@gmail.com"}] From 883fdca9d7c1fc4922509fda2dc5e979a6719c2c Mon Sep 17 00:00:00 2001 From: YM162 Date: Sun, 24 Dec 2023 04:37:02 +0100 Subject: [PATCH 21/27] Added npm registry --- .github/workflows/wasm_publish.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/workflows/wasm_publish.yml b/.github/workflows/wasm_publish.yml index 42d50e8..43dc285 100644 --- a/.github/workflows/wasm_publish.yml +++ b/.github/workflows/wasm_publish.yml @@ -32,7 +32,6 @@ jobs: # MESSAGE: "Build: ({sha}) {msg}" # The commit message - name: setup node - working-directory: ./gulagcleaner_wasm/WASM_build uses: actions/setup-node@v3 with: node-version: '20.x' From 26a1a3b4c234c047f3e7b29dbee43953d5188a96 Mon Sep 17 00:00:00 2001 From: YM162 Date: Sun, 24 Dec 2023 04:38:38 +0100 Subject: [PATCH 22/27] Added npm registry --- .github/workflows/wasm_publish.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/wasm_publish.yml b/.github/workflows/wasm_publish.yml index 43dc285..8dae873 100644 --- a/.github/workflows/wasm_publish.yml +++ b/.github/workflows/wasm_publish.yml @@ -37,9 +37,9 @@ jobs: node-version: '20.x' registry-url: 'https://registry.npmjs.org' - - name: run ci + - name: run install working-directory: ./gulagcleaner_wasm/WASM_build - run: npm ci + run: npm install - name: publish to npm working-directory: ./gulagcleaner_wasm/WASM_build From dd9086c1ad4a3d2721eb866396faf10488d063e9 Mon Sep 17 00:00:00 2001 From: YM162 Date: Sun, 24 Dec 2023 05:12:52 +0100 Subject: [PATCH 23/27] Changed workflows --- .github/workflows/cargo_publish | 26 ++++++++++++++++++++++++++ .github/workflows/pypi_publish.yml | 10 +++------- .github/workflows/wasm_publish.yml | 21 ++++----------------- 3 files changed, 33 insertions(+), 24 deletions(-) create mode 100644 .github/workflows/cargo_publish diff --git a/.github/workflows/cargo_publish b/.github/workflows/cargo_publish new file mode 100644 index 0000000..af82a42 --- /dev/null +++ b/.github/workflows/cargo_publish @@ -0,0 +1,26 @@ +name: Publish to crates registry + +# on: +# release: +# types: [published] + +on: + push: + branches: + - rust_bindings + +jobs: + build: + runs-on: ubuntu-latest + name: Publish to crates registry + steps: + - uses: actions/checkout@v3 + - uses: actions-rs/toolchain@v1 + with: + toolchain: stable + override: true + - uses: katyo/publish-crates@v2 + with: + registry-token: ${{ secrets.CARGO_REGISTRY_TOKEN }} + path: './gulagcleaner_rs' + dry-run: true diff --git a/.github/workflows/pypi_publish.yml b/.github/workflows/pypi_publish.yml index 5d163c5..2b06fa4 100644 --- a/.github/workflows/pypi_publish.yml +++ b/.github/workflows/pypi_publish.yml @@ -1,12 +1,8 @@ -name: Publish to PyPI +name: Bind from Python/Build wheels and publish to PyPI on: - push: - branches: - - main - tags: - - '**' - pull_request: {} + release: + types: [published] jobs: build: diff --git a/.github/workflows/wasm_publish.yml b/.github/workflows/wasm_publish.yml index 8dae873..ea83ee9 100644 --- a/.github/workflows/wasm_publish.yml +++ b/.github/workflows/wasm_publish.yml @@ -1,14 +1,13 @@ -name: Build WASM and publish in the WASM_build branch +name: Build as WASM and publish in npm on: - push: - branches: - - rust_bindings + release: + types: [published] jobs: build: runs-on: ubuntu-latest - name: Build and Push + name: Build and publish to npm steps: - name: git-checkout uses: actions/checkout@v4 @@ -19,18 +18,6 @@ jobs: - name: build wasm run: wasm-pack build gulagcleaner_wasm --target web --release -d WASM_build - # - name: remove gitignore - # run: rm gulagcleaner_wasm/WASM_build/.gitignore - - # - name: push to the WASM_build branch - # uses: s0/git-publish-subdir-action@develop - # env: - # REPO: self - # BRANCH: WASM_build # The branch name where you want to push the assets - # FOLDER: gulagcleaner_wasm/WASM_build # The directory where your assets are generated - # GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # GitHub will automatically add this - you don't need to bother getting a token - # MESSAGE: "Build: ({sha}) {msg}" # The commit message - - name: setup node uses: actions/setup-node@v3 with: From f550472aecdfdbc76f1f54ba2e4c77f0a8c98ebf Mon Sep 17 00:00:00 2001 From: YM162 Date: Sun, 24 Dec 2023 05:15:03 +0100 Subject: [PATCH 24/27] Typo in workflow --- .github/workflows/{cargo_publish => cargo_publish.yml} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename .github/workflows/{cargo_publish => cargo_publish.yml} (100%) diff --git a/.github/workflows/cargo_publish b/.github/workflows/cargo_publish.yml similarity index 100% rename from .github/workflows/cargo_publish rename to .github/workflows/cargo_publish.yml From 411dbe9649dba112774a0fcf3f3410e1dd0cb6ce Mon Sep 17 00:00:00 2001 From: YM162 Date: Sun, 24 Dec 2023 05:22:51 +0100 Subject: [PATCH 25/27] Fixed cargo publish --- .github/workflows/cargo_publish.yml | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/.github/workflows/cargo_publish.yml b/.github/workflows/cargo_publish.yml index af82a42..d1556f0 100644 --- a/.github/workflows/cargo_publish.yml +++ b/.github/workflows/cargo_publish.yml @@ -14,13 +14,14 @@ jobs: runs-on: ubuntu-latest name: Publish to crates registry steps: - - uses: actions/checkout@v3 - - uses: actions-rs/toolchain@v1 - with: - toolchain: stable - override: true - - uses: katyo/publish-crates@v2 - with: - registry-token: ${{ secrets.CARGO_REGISTRY_TOKEN }} - path: './gulagcleaner_rs' - dry-run: true + - name: Checkout sources + uses: actions/checkout@v2 + - name: Install stable toolchain + uses: actions-rs/toolchain@v1 + with: + profile: minimal + toolchain: stable + override: true + - run: cargo publish -p gulagcleaner_rs --token ${CARGO_REGISTRY_TOKEN} + env: + CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_REGISTRY_TOKEN }} \ No newline at end of file From 701cc23ca5a57b459d0b2f0500725f548f64367a Mon Sep 17 00:00:00 2001 From: YM162 Date: Sun, 24 Dec 2023 05:28:02 +0100 Subject: [PATCH 26/27] 0.10.1 --- README.md | 13 ++++++++----- gulagcleaner_python/Cargo.toml | 4 ++-- gulagcleaner_python/README.md | 13 ++++++++----- gulagcleaner_python/pyproject.toml | 4 ++-- gulagcleaner_python/python/gulagcleaner/clean.py | 8 ++------ .../python/gulagcleaner/command_line.py | 13 +++++++------ gulagcleaner_rs/Cargo.toml | 4 ++-- gulagcleaner_rs/src/lib.rs | 3 ++- gulagcleaner_wasm/Cargo.toml | 4 ++-- 9 files changed, 35 insertions(+), 31 deletions(-) diff --git a/README.md b/README.md index 51fd410..b503120 100644 --- a/README.md +++ b/README.md @@ -35,7 +35,7 @@ Gulag Cleaner can be used through both a Command Line Interface (CLI) and in you To use Gulag Cleaner through the CLI, simply run the following command, replacing `` with the name of one or more PDF files or folders containing PDF: ``` -gulagcleaner [-r] [-s] [-h] [-v] ... +gulagcleaner [-r] [-s] [-n] [-h] [-v] ... ``` ## Options @@ -44,6 +44,7 @@ Gulag Cleaner provides several options for its usage: > * '-r': Replace the original file with the cleaned version. > * '-s': Do not show metadata about cleaned files. +> * '-n': Force the naive cleaning method. > * '-h': Display the help message, providing information on how to use Gulag Cleaner. > * '-v': Display the current version of Gulag Cleaner. @@ -54,7 +55,7 @@ To use Gulag Cleaner in your code, you can use the following code snippet: ```python from gulagcleaner.extract import clean_pdf -return_msg = clean_pdf("file.pdf") +return_msg = clean_pdf_path("input.pdf","output.pdf") ``` # License @@ -66,6 +67,8 @@ We're always looking for ways to improve Gulag Cleaner, and we welcome contribut ## TODO If you want to help, these are the top priorities right now: -* Revamp the argument parsing. We should use some parsing library to allow for short "-v" and long "--version" arguments. Idealy it should support parameters for each argument. - -* Add the "Naive" cleaning method. This method is just a fallback that crops the Ads by zooming in and moving the MediaBox. This is not ideal, but there will always be edge cases not covered in the other methods and doing this better than giving an error. \ No newline at end of file +* Write tests for the package. +* Add README.md (With code examples) for the rust and JS distributions. +* Add comments to a lot of the rust code. +* Optimize the rust code for performance improvements. +* Add a new "clean_pdf_bytes()" function in python that does not require a file path, just the bytes. \ No newline at end of file diff --git a/gulagcleaner_python/Cargo.toml b/gulagcleaner_python/Cargo.toml index d1fce8b..3da3d20 100644 --- a/gulagcleaner_python/Cargo.toml +++ b/gulagcleaner_python/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "gulagcleaner_python" -version = "0.10.0" +version = "0.10.1" edition = "2021" authors = ["YM162 "] description = "Ad removal tool for PDFs." @@ -8,7 +8,7 @@ readme = "../README.md" homepage = "https://github.com/YM162/gulag-cleaner-cli" repository = "https://github.com/YM162/gulag-cleaner-cli.git" license-file = "../LICENSE" -keywords = ["wuolah", "pdf", "ads", "advertisments", "cleaner", "gulagcleaner"] +keywords = ["wuolah", "pdf", "ads", "advertisments", "gulagcleaner"] [lib] name = "gulagcleaner_python" diff --git a/gulagcleaner_python/README.md b/gulagcleaner_python/README.md index 51fd410..b503120 100644 --- a/gulagcleaner_python/README.md +++ b/gulagcleaner_python/README.md @@ -35,7 +35,7 @@ Gulag Cleaner can be used through both a Command Line Interface (CLI) and in you To use Gulag Cleaner through the CLI, simply run the following command, replacing `` with the name of one or more PDF files or folders containing PDF: ``` -gulagcleaner [-r] [-s] [-h] [-v] ... +gulagcleaner [-r] [-s] [-n] [-h] [-v] ... ``` ## Options @@ -44,6 +44,7 @@ Gulag Cleaner provides several options for its usage: > * '-r': Replace the original file with the cleaned version. > * '-s': Do not show metadata about cleaned files. +> * '-n': Force the naive cleaning method. > * '-h': Display the help message, providing information on how to use Gulag Cleaner. > * '-v': Display the current version of Gulag Cleaner. @@ -54,7 +55,7 @@ To use Gulag Cleaner in your code, you can use the following code snippet: ```python from gulagcleaner.extract import clean_pdf -return_msg = clean_pdf("file.pdf") +return_msg = clean_pdf_path("input.pdf","output.pdf") ``` # License @@ -66,6 +67,8 @@ We're always looking for ways to improve Gulag Cleaner, and we welcome contribut ## TODO If you want to help, these are the top priorities right now: -* Revamp the argument parsing. We should use some parsing library to allow for short "-v" and long "--version" arguments. Idealy it should support parameters for each argument. - -* Add the "Naive" cleaning method. This method is just a fallback that crops the Ads by zooming in and moving the MediaBox. This is not ideal, but there will always be edge cases not covered in the other methods and doing this better than giving an error. \ No newline at end of file +* Write tests for the package. +* Add README.md (With code examples) for the rust and JS distributions. +* Add comments to a lot of the rust code. +* Optimize the rust code for performance improvements. +* Add a new "clean_pdf_bytes()" function in python that does not require a file path, just the bytes. \ No newline at end of file diff --git a/gulagcleaner_python/pyproject.toml b/gulagcleaner_python/pyproject.toml index 297d3e7..f3814f7 100644 --- a/gulagcleaner_python/pyproject.toml +++ b/gulagcleaner_python/pyproject.toml @@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta" [project] name = "gulagcleaner" -version = "0.10.0" +version = "0.10.1" description = "Ad removal tool for PDFs." authors = [ {name = "YM162", email = "david.fontaneda16@gmail.com"}] @@ -16,7 +16,7 @@ license = {file = "LICENSE"} classifiers = ["Programming Language :: Python :: 3", "License :: OSI Approved :: MIT License", "Operating System :: OS Independent"] -keywords = ["wuolah", "pdf", "ads", "advertisments", "cleaner", "gulagcleaner"] +keywords = ["wuolah", "pdf", "ads", "advertisments", "gulagcleaner"] [project.urls] homepage = "https://github.com/YM162/gulag-cleaner-cli" diff --git a/gulagcleaner_python/python/gulagcleaner/clean.py b/gulagcleaner_python/python/gulagcleaner/clean.py index 5bde636..7fcc224 100644 --- a/gulagcleaner_python/python/gulagcleaner/clean.py +++ b/gulagcleaner_python/python/gulagcleaner/clean.py @@ -1,6 +1,6 @@ from ._lib import clean_pdf # export public parts of the binary extension -def clean_pdf_path(pdf_path, output_path, force_naive): +def clean_pdf_path(pdf_path, output_path, force_naive=False): """ Cleans the ads from the PDF file in a given path and saves it in another path. Args: @@ -11,7 +11,6 @@ def clean_pdf_path(pdf_path, output_path, force_naive): return_msg (dict): A dictionary with the following keys: success (bool): Indicates whether the de-embedding process was successful. return_path (str): The path to the cleaned file if successful. - method (str): The method used to clean the file. error (str): An error description if the process was unsuccessful. """ try: @@ -19,15 +18,12 @@ def clean_pdf_path(pdf_path, output_path, force_naive): pdf = f.read() cleaned_pdf = clean_pdf(pdf, force_naive) with open(output_path, "wb") as f: - method = cleaned_pdf[len(cleaned_pdf)-1] - cleaned_pdf = cleaned_pdf[0:len(cleaned_pdf)-1] f.write(bytes(cleaned_pdf)) return {"success": True, "return_path": output_path, - "method": method, "error": ""} except Exception as e: - return {"success": False, "return_path": "","method":"", "error": str(e)} + return {"success": False, "return_path": "", "error": str(e)} # I would like to expose the clean_pdf function as a "clean_pdf_bytes(bytes)" function that already removes the trailing method byte and returns the cleaned bytes and the method. # Working on it. \ No newline at end of file diff --git a/gulagcleaner_python/python/gulagcleaner/command_line.py b/gulagcleaner_python/python/gulagcleaner/command_line.py index 15acfc1..9653fb4 100644 --- a/gulagcleaner_python/python/gulagcleaner/command_line.py +++ b/gulagcleaner_python/python/gulagcleaner/command_line.py @@ -33,9 +33,10 @@ def main(): location. Available CLI arguments: - -h : Display help information. -r : Replace original files with their cleaned version. -s : Do not show metadata about cleaned files. + -n : Force the naive cleaning method. + -h : Display help information. -v : Display the version of the program. ''' @@ -43,7 +44,7 @@ def main(): # Check for the -h argument if arguments["help"]: - print("Usage: gulagcleaner [-h] [-r] [-s] [-v] [-n] ") + print("Usage: gulagcleaner [-r] [-s] [-n] [-h] [-v] ") print("") print("Removes ads from PDF files.") print("") @@ -51,21 +52,21 @@ def main(): print(" pdf_path PDF file to clean.") print("") print("Optional arguments:") - print(" -h Show this help message.") print(" -r Replace original files with their cleaned version.") print(" -s Do not show metadata about cleaned files.") - print(" -v Show the version of the program.") print(" -n Force the naive cleaning method.") + print(" -h Show this help message.") + print(" -v Show the version of the program.") return # Check for the -v argument if arguments["version"]: - print("Current version: 0.8.2") + print("Current version: 0.10.1") return # Get the pdf_path argument if len(arguments["files"]) == 0: - print('Usage: gulagcleaner [-h] [-r] [-s] [-v] [-n] ...') + print('Usage: gulagcleaner [-r] [-s] [-n] [-h] [-v] ...') return replace = arguments["replace"] diff --git a/gulagcleaner_rs/Cargo.toml b/gulagcleaner_rs/Cargo.toml index 738908a..e1151e4 100644 --- a/gulagcleaner_rs/Cargo.toml +++ b/gulagcleaner_rs/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "gulagcleaner_rs" -version = "0.10.0" +version = "0.10.1" edition = "2021" authors = ["YM162 "] description = "Ad removal tool for PDFs." @@ -8,7 +8,7 @@ readme = "../README.md" homepage = "https://github.com/YM162/gulag-cleaner-cli" repository = "https://github.com/YM162/gulag-cleaner-cli.git" license-file = "../LICENSE" -keywords = ["wuolah", "pdf", "ads", "advertisments", "cleaner", "gulagcleaner"] +keywords = ["wuolah", "pdf", "ads", "advertisments", "gulagcleaner"] [lib] name = "gulagcleaner_rs" diff --git a/gulagcleaner_rs/src/lib.rs b/gulagcleaner_rs/src/lib.rs index cc0876f..1bd210a 100644 --- a/gulagcleaner_rs/src/lib.rs +++ b/gulagcleaner_rs/src/lib.rs @@ -190,7 +190,8 @@ pub fn clean_pdf(data: Vec,force_naive: u8) -> Vec { let mut return_stream = Vec::new(); doc.save_to(&mut return_stream).unwrap(); - return_stream.push(method_code); + // Should we still return the method_code now that we are going multi-language? I will leave it not returned for now. + //return_stream.push(method_code); return_stream //doc.save_to("test.pdf").unwrap(); } diff --git a/gulagcleaner_wasm/Cargo.toml b/gulagcleaner_wasm/Cargo.toml index 3f9875a..d79c4f8 100644 --- a/gulagcleaner_wasm/Cargo.toml +++ b/gulagcleaner_wasm/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "gulagcleaner_wasm" -version = "0.10.0" +version = "0.10.1" edition = "2021" authors = ["YM162 "] description = "Ad removal tool for PDFs." @@ -8,7 +8,7 @@ readme = "../README.md" homepage = "https://github.com/YM162/gulag-cleaner-cli" repository = "https://github.com/YM162/gulag-cleaner-cli.git" license-file = "../LICENSE" -keywords = ["wuolah", "pdf", "ads", "advertisments", "cleaner", "gulagcleaner"] +keywords = ["wuolah", "pdf", "ads", "advertisments", "gulagcleaner"] [lib] crate-type = ["cdylib"] From 17ee0e1732948e52925676a502c64e7cb11d58b2 Mon Sep 17 00:00:00 2001 From: YM162 Date: Sun, 24 Dec 2023 05:35:56 +0100 Subject: [PATCH 27/27] Relase 0.10.2 --- .github/workflows/cargo_publish.yml | 9 ++------- gulagcleaner_python/Cargo.toml | 4 ++-- gulagcleaner_python/pyproject.toml | 2 +- gulagcleaner_python/python/gulagcleaner/command_line.py | 2 +- gulagcleaner_rs/Cargo.toml | 4 ++-- gulagcleaner_wasm/Cargo.toml | 4 ++-- 6 files changed, 10 insertions(+), 15 deletions(-) diff --git a/.github/workflows/cargo_publish.yml b/.github/workflows/cargo_publish.yml index d1556f0..23c0f1a 100644 --- a/.github/workflows/cargo_publish.yml +++ b/.github/workflows/cargo_publish.yml @@ -1,13 +1,8 @@ name: Publish to crates registry -# on: -# release: -# types: [published] - on: - push: - branches: - - rust_bindings + release: + types: [published] jobs: build: diff --git a/gulagcleaner_python/Cargo.toml b/gulagcleaner_python/Cargo.toml index 3da3d20..17e168e 100644 --- a/gulagcleaner_python/Cargo.toml +++ b/gulagcleaner_python/Cargo.toml @@ -1,13 +1,13 @@ [package] name = "gulagcleaner_python" -version = "0.10.1" +version = "0.10.2" edition = "2021" authors = ["YM162 "] description = "Ad removal tool for PDFs." readme = "../README.md" homepage = "https://github.com/YM162/gulag-cleaner-cli" repository = "https://github.com/YM162/gulag-cleaner-cli.git" -license-file = "../LICENSE" +license = "GPL-3.0" keywords = ["wuolah", "pdf", "ads", "advertisments", "gulagcleaner"] [lib] diff --git a/gulagcleaner_python/pyproject.toml b/gulagcleaner_python/pyproject.toml index f3814f7..cc99758 100644 --- a/gulagcleaner_python/pyproject.toml +++ b/gulagcleaner_python/pyproject.toml @@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta" [project] name = "gulagcleaner" -version = "0.10.1" +version = "0.10.2" description = "Ad removal tool for PDFs." authors = [ {name = "YM162", email = "david.fontaneda16@gmail.com"}] diff --git a/gulagcleaner_python/python/gulagcleaner/command_line.py b/gulagcleaner_python/python/gulagcleaner/command_line.py index 9653fb4..f83ff7c 100644 --- a/gulagcleaner_python/python/gulagcleaner/command_line.py +++ b/gulagcleaner_python/python/gulagcleaner/command_line.py @@ -61,7 +61,7 @@ def main(): # Check for the -v argument if arguments["version"]: - print("Current version: 0.10.1") + print("Current version: 0.10.2") return # Get the pdf_path argument diff --git a/gulagcleaner_rs/Cargo.toml b/gulagcleaner_rs/Cargo.toml index e1151e4..eb8d29f 100644 --- a/gulagcleaner_rs/Cargo.toml +++ b/gulagcleaner_rs/Cargo.toml @@ -1,13 +1,13 @@ [package] name = "gulagcleaner_rs" -version = "0.10.1" +version = "0.10.2" edition = "2021" authors = ["YM162 "] description = "Ad removal tool for PDFs." readme = "../README.md" homepage = "https://github.com/YM162/gulag-cleaner-cli" repository = "https://github.com/YM162/gulag-cleaner-cli.git" -license-file = "../LICENSE" +license = "GPL-3.0" keywords = ["wuolah", "pdf", "ads", "advertisments", "gulagcleaner"] [lib] diff --git a/gulagcleaner_wasm/Cargo.toml b/gulagcleaner_wasm/Cargo.toml index d79c4f8..620e1c2 100644 --- a/gulagcleaner_wasm/Cargo.toml +++ b/gulagcleaner_wasm/Cargo.toml @@ -1,13 +1,13 @@ [package] name = "gulagcleaner_wasm" -version = "0.10.1" +version = "0.10.2" edition = "2021" authors = ["YM162 "] description = "Ad removal tool for PDFs." readme = "../README.md" homepage = "https://github.com/YM162/gulag-cleaner-cli" repository = "https://github.com/YM162/gulag-cleaner-cli.git" -license-file = "../LICENSE" +license = "GPL-3.0" keywords = ["wuolah", "pdf", "ads", "advertisments", "gulagcleaner"] [lib]