gitignorio-cli 0.1.0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- gitignore_cli/__init__.py +3 -0
- gitignore_cli/cli.py +193 -0
- gitignore_cli/data/list.txt +571 -0
- gitignore_cli/data/manifest.json +5 -0
- gitignore_cli/data/order.json +7 -0
- gitignore_cli/data/templates/1c-bitrix.gitignore +30 -0
- gitignore_cli/data/templates/1c.gitignore +12 -0
- gitignore_cli/data/templates/a-frame.gitignore +47 -0
- gitignore_cli/data/templates/actionscript.gitignore +24 -0
- gitignore_cli/data/templates/ada.gitignore +11 -0
- gitignore_cli/data/templates/adobe.gitignore +12 -0
- gitignore_cli/data/templates/advancedinstaller.gitignore +10 -0
- gitignore_cli/data/templates/adventuregamestudio.gitignore +37 -0
- gitignore_cli/data/templates/agda.gitignore +8 -0
- gitignore_cli/data/templates/al.gitignore +17 -0
- gitignore_cli/data/templates/alteraquartusii.gitignore +59 -0
- gitignore_cli/data/templates/altium.gitignore +24 -0
- gitignore_cli/data/templates/amplify.gitignore +21 -0
- gitignore_cli/data/templates/android.gitignore +45 -0
- gitignore_cli/data/templates/androidstudio.gitignore +136 -0
- gitignore_cli/data/templates/angular.gitignore +36 -0
- gitignore_cli/data/templates/anjuta.gitignore +9 -0
- gitignore_cli/data/templates/ansible.gitignore +7 -0
- gitignore_cli/data/templates/ansibletower.gitignore +31 -0
- gitignore_cli/data/templates/apachecordova.gitignore +13 -0
- gitignore_cli/data/templates/apachehadoop.gitignore +22 -0
- gitignore_cli/data/templates/appbuilder.gitignore +7 -0
- gitignore_cli/data/templates/appceleratortitanium.gitignore +9 -0
- gitignore_cli/data/templates/appcode+all.gitignore +92 -0
- gitignore_cli/data/templates/appcode+iml.gitignore +91 -0
- gitignore_cli/data/templates/appcode.gitignore +117 -0
- gitignore_cli/data/templates/appengine.gitignore +8 -0
- gitignore_cli/data/templates/aptanastudio.gitignore +66 -0
- gitignore_cli/data/templates/arcanist.gitignore +8 -0
- gitignore_cli/data/templates/archive.gitignore +43 -0
- gitignore_cli/data/templates/archives.gitignore +38 -0
- gitignore_cli/data/templates/archlinuxpackages.gitignore +19 -0
- gitignore_cli/data/templates/asdf.gitignore +7 -0
- gitignore_cli/data/templates/aspnetcore.gitignore +274 -0
- gitignore_cli/data/templates/assembler.gitignore +10 -0
- gitignore_cli/data/templates/astro.gitignore +9 -0
- gitignore_cli/data/templates/ate.gitignore +66 -0
- gitignore_cli/data/templates/atmelstudio.gitignore +28 -0
- gitignore_cli/data/templates/ats.gitignore +13 -0
- gitignore_cli/data/templates/audio.gitignore +18 -0
- gitignore_cli/data/templates/autohotkey.gitignore +53 -0
- gitignore_cli/data/templates/automationstudio.gitignore +27 -0
- gitignore_cli/data/templates/autotools+strict.gitignore +62 -0
- gitignore_cli/data/templates/autotools.gitignore +60 -0
- gitignore_cli/data/templates/awr.gitignore +13 -0
- gitignore_cli/data/templates/azurefunctions.gitignore +8 -0
- gitignore_cli/data/templates/azurite.gitignore +19 -0
- gitignore_cli/data/templates/backup.gitignore +11 -0
- gitignore_cli/data/templates/ballerina.gitignore +50 -0
- gitignore_cli/data/templates/basercms.gitignore +46 -0
- gitignore_cli/data/templates/basic.gitignore +14 -0
- gitignore_cli/data/templates/batch.gitignore +10 -0
- gitignore_cli/data/templates/bazaar.gitignore +8 -0
- gitignore_cli/data/templates/bazel.gitignore +19 -0
- gitignore_cli/data/templates/bitrise.gitignore +7 -0
- gitignore_cli/data/templates/bitrix.gitignore +29 -0
- gitignore_cli/data/templates/bittorrent.gitignore +7 -0
- gitignore_cli/data/templates/blackbox.gitignore +10 -0
- gitignore_cli/data/templates/blender.gitignore +8 -0
- gitignore_cli/data/templates/bloop.gitignore +7 -0
- gitignore_cli/data/templates/bluej.gitignore +13 -0
- gitignore_cli/data/templates/bookdown.gitignore +8 -0
- gitignore_cli/data/templates/bower.gitignore +10 -0
- gitignore_cli/data/templates/bricxcc.gitignore +10 -0
- gitignore_cli/data/templates/buck.gitignore +11 -0
- gitignore_cli/data/templates/c++.gitignore +38 -0
- gitignore_cli/data/templates/c.gitignore +58 -0
- gitignore_cli/data/templates/cake.gitignore +8 -0
- gitignore_cli/data/templates/cakephp.gitignore +31 -0
- gitignore_cli/data/templates/cakephp2.gitignore +12 -0
- gitignore_cli/data/templates/cakephp3.gitignore +13 -0
- gitignore_cli/data/templates/calabash.gitignore +16 -0
- gitignore_cli/data/templates/carthage.gitignore +12 -0
- gitignore_cli/data/templates/certificates.gitignore +12 -0
- gitignore_cli/data/templates/ceylon.gitignore +15 -0
- gitignore_cli/data/templates/cfwheels.gitignore +18 -0
- gitignore_cli/data/templates/chefcookbook.gitignore +15 -0
- gitignore_cli/data/templates/chocolatey.gitignore +8 -0
- gitignore_cli/data/templates/circuitpython.gitignore +10 -0
- gitignore_cli/data/templates/clean.gitignore +20 -0
- gitignore_cli/data/templates/clion+all.gitignore +92 -0
- gitignore_cli/data/templates/clion+iml.gitignore +91 -0
- gitignore_cli/data/templates/clion.gitignore +117 -0
- gitignore_cli/data/templates/clojure.gitignore +20 -0
- gitignore_cli/data/templates/cloud9.gitignore +9 -0
- gitignore_cli/data/templates/cmake.gitignore +23 -0
- gitignore_cli/data/templates/cocoapods.gitignore +12 -0
- gitignore_cli/data/templates/cocos2dx.gitignore +156 -0
- gitignore_cli/data/templates/cocoscreator.gitignore +69 -0
- gitignore_cli/data/templates/codeblocks.gitignore +12 -0
- gitignore_cli/data/templates/codecomposerstudio.gitignore +29 -0
- gitignore_cli/data/templates/codeigniter.gitignore +26 -0
- gitignore_cli/data/templates/codeio.gitignore +7 -0
- gitignore_cli/data/templates/codekit.gitignore +14 -0
- gitignore_cli/data/templates/codesniffer.gitignore +12 -0
- gitignore_cli/data/templates/coffeescript.gitignore +7 -0
- gitignore_cli/data/templates/commonlisp.gitignore +23 -0
- gitignore_cli/data/templates/compodoc.gitignore +10 -0
- gitignore_cli/data/templates/composer.gitignore +12 -0
- gitignore_cli/data/templates/compressed.gitignore +18 -0
- gitignore_cli/data/templates/compressedarchive.gitignore +142 -0
- gitignore_cli/data/templates/compression.gitignore +43 -0
- gitignore_cli/data/templates/conan.gitignore +26 -0
- gitignore_cli/data/templates/concrete5.gitignore +27 -0
- gitignore_cli/data/templates/coq.gitignore +51 -0
- gitignore_cli/data/templates/cordova.gitignore +16 -0
- gitignore_cli/data/templates/craftcms.gitignore +10 -0
- gitignore_cli/data/templates/crashlytics.gitignore +11 -0
- gitignore_cli/data/templates/crbasic.gitignore +11 -0
- gitignore_cli/data/templates/crossbar.gitignore +7 -0
- gitignore_cli/data/templates/crystal.gitignore +15 -0
- gitignore_cli/data/templates/cs-cart.gitignore +58 -0
- gitignore_cli/data/templates/csharp.gitignore +402 -0
- gitignore_cli/data/templates/cuda.gitignore +12 -0
- gitignore_cli/data/templates/cvs.gitignore +10 -0
- gitignore_cli/data/templates/cypressio.gitignore +13 -0
- gitignore_cli/data/templates/d.gitignore +37 -0
- gitignore_cli/data/templates/dart.gitignore +37 -0
- gitignore_cli/data/templates/darteditor.gitignore +8 -0
- gitignore_cli/data/templates/data.gitignore +18 -0
- gitignore_cli/data/templates/database.gitignore +14 -0
- gitignore_cli/data/templates/datarecovery.gitignore +16 -0
- gitignore_cli/data/templates/dbeaver.gitignore +8 -0
- gitignore_cli/data/templates/dbt.gitignore +10 -0
- gitignore_cli/data/templates/defold.gitignore +16 -0
- gitignore_cli/data/templates/delphi.gitignore +69 -0
- gitignore_cli/data/templates/deno.gitignore +15 -0
- gitignore_cli/data/templates/dframe.gitignore +22 -0
- gitignore_cli/data/templates/diff.gitignore +8 -0
- gitignore_cli/data/templates/direnv.gitignore +8 -0
- gitignore_cli/data/templates/diskimage.gitignore +10 -0
- gitignore_cli/data/templates/django.gitignore +174 -0
- gitignore_cli/data/templates/dm.gitignore +11 -0
- gitignore_cli/data/templates/docfx.gitignore +8 -0
- gitignore_cli/data/templates/docpress.gitignore +9 -0
- gitignore_cli/data/templates/docusaurus.gitignore +141 -0
- gitignore_cli/data/templates/docz.gitignore +8 -0
- gitignore_cli/data/templates/dotenv.gitignore +7 -0
- gitignore_cli/data/templates/dotfilessh.gitignore +8 -0
- gitignore_cli/data/templates/dotnetcore.gitignore +13 -0
- gitignore_cli/data/templates/dotsettings.gitignore +7 -0
- gitignore_cli/data/templates/doxygen.gitignore +8 -0
- gitignore_cli/data/templates/dreamweaver.gitignore +13 -0
- gitignore_cli/data/templates/dropbox.gitignore +10 -0
- gitignore_cli/data/templates/drupal.gitignore +67 -0
- gitignore_cli/data/templates/drupal7.gitignore +49 -0
- gitignore_cli/data/templates/drupal8.gitignore +67 -0
- gitignore_cli/data/templates/e2studio.gitignore +17 -0
- gitignore_cli/data/templates/eagle.gitignore +57 -0
- gitignore_cli/data/templates/easybook.gitignore +8 -0
- gitignore_cli/data/templates/eclipse.gitignore +70 -0
- gitignore_cli/data/templates/eiffelstudio.gitignore +8 -0
- gitignore_cli/data/templates/elasticbeanstalk.gitignore +7 -0
- gitignore_cli/data/templates/elisp.gitignore +17 -0
- gitignore_cli/data/templates/elixir.gitignore +18 -0
- gitignore_cli/data/templates/elm.gitignore +10 -0
- gitignore_cli/data/templates/emacs.gitignore +55 -0
- gitignore_cli/data/templates/ember.gitignore +22 -0
- gitignore_cli/data/templates/ensime.gitignore +10 -0
- gitignore_cli/data/templates/episerver.gitignore +9 -0
- gitignore_cli/data/templates/erlang.gitignore +26 -0
- gitignore_cli/data/templates/espresso.gitignore +7 -0
- gitignore_cli/data/templates/executable.gitignore +16 -0
- gitignore_cli/data/templates/exercism.gitignore +11 -0
- gitignore_cli/data/templates/expressionengine.gitignore +25 -0
- gitignore_cli/data/templates/extjs.gitignore +20 -0
- gitignore_cli/data/templates/fancy.gitignore +8 -0
- gitignore_cli/data/templates/fastlane.gitignore +27 -0
- gitignore_cli/data/templates/finale.gitignore +19 -0
- gitignore_cli/data/templates/firebase.gitignore +13 -0
- gitignore_cli/data/templates/fish.gitignore +10 -0
- gitignore_cli/data/templates/flashbuilder.gitignore +27 -0
- gitignore_cli/data/templates/flask.gitignore +170 -0
- gitignore_cli/data/templates/flatpak.gitignore +10 -0
- gitignore_cli/data/templates/flex.gitignore +27 -0
- gitignore_cli/data/templates/flexbuilder.gitignore +9 -0
- gitignore_cli/data/templates/floobits.gitignore +7 -0
- gitignore_cli/data/templates/flutter.gitignore +68 -0
- gitignore_cli/data/templates/font.gitignore +10 -0
- gitignore_cli/data/templates/fontforge.gitignore +19 -0
- gitignore_cli/data/templates/forcedotcom.gitignore +10 -0
- gitignore_cli/data/templates/forgegradle.gitignore +8 -0
- gitignore_cli/data/templates/fortran.gitignore +38 -0
- gitignore_cli/data/templates/freecad.gitignore +11 -0
- gitignore_cli/data/templates/freepascal.gitignore +18 -0
- gitignore_cli/data/templates/fsharp.gitignore +18 -0
- gitignore_cli/data/templates/fuelphp.gitignore +27 -0
- gitignore_cli/data/templates/fusetools.gitignore +11 -0
- gitignore_cli/data/templates/games.gitignore +10 -0
- gitignore_cli/data/templates/gatsby.gitignore +12 -0
- gitignore_cli/data/templates/gcov.gitignore +11 -0
- gitignore_cli/data/templates/genero4gl.gitignore +36 -0
- gitignore_cli/data/templates/geth.gitignore +16 -0
- gitignore_cli/data/templates/ggts.gitignore +24 -0
- gitignore_cli/data/templates/gis.gitignore +8 -0
- gitignore_cli/data/templates/git.gitignore +19 -0
- gitignore_cli/data/templates/gitbook.gitignore +22 -0
- gitignore_cli/data/templates/go.gitignore +27 -0
- gitignore_cli/data/templates/godot.gitignore +21 -0
- gitignore_cli/data/templates/goland+all.gitignore +92 -0
- gitignore_cli/data/templates/goland+iml.gitignore +91 -0
- gitignore_cli/data/templates/goland.gitignore +117 -0
- gitignore_cli/data/templates/goodsync.gitignore +7 -0
- gitignore_cli/data/templates/gpg.gitignore +8 -0
- gitignore_cli/data/templates/gradle.gitignore +31 -0
- gitignore_cli/data/templates/grails.gitignore +39 -0
- gitignore_cli/data/templates/greenfoot.gitignore +14 -0
- gitignore_cli/data/templates/groovy.gitignore +30 -0
- gitignore_cli/data/templates/grunt.gitignore +11 -0
- gitignore_cli/data/templates/gwt.gitignore +31 -0
- gitignore_cli/data/templates/haskell.gitignore +29 -0
- gitignore_cli/data/templates/helm.gitignore +8 -0
- gitignore_cli/data/templates/hexo.gitignore +9 -0
- gitignore_cli/data/templates/hol.gitignore +17 -0
- gitignore_cli/data/templates/homeassistant.gitignore +48 -0
- gitignore_cli/data/templates/homebrew.gitignore +7 -0
- gitignore_cli/data/templates/hsp.gitignore +15 -0
- gitignore_cli/data/templates/hugo.gitignore +19 -0
- gitignore_cli/data/templates/hyperledgercomposer.gitignore +71 -0
- gitignore_cli/data/templates/iar.gitignore +53 -0
- gitignore_cli/data/templates/iar_ewarm.gitignore +25 -0
- gitignore_cli/data/templates/iarembeddedworkbench.gitignore +55 -0
- gitignore_cli/data/templates/idapro.gitignore +20 -0
- gitignore_cli/data/templates/idris.gitignore +13 -0
- gitignore_cli/data/templates/igorpro.gitignore +11 -0
- gitignore_cli/data/templates/images.gitignore +69 -0
- gitignore_cli/data/templates/infer.gitignore +8 -0
- gitignore_cli/data/templates/inforcms.gitignore +21 -0
- gitignore_cli/data/templates/inforcrm.gitignore +40 -0
- gitignore_cli/data/templates/intellij+all.gitignore +92 -0
- gitignore_cli/data/templates/intellij+iml.gitignore +91 -0
- gitignore_cli/data/templates/intellij.gitignore +117 -0
- gitignore_cli/data/templates/ionic3.gitignore +38 -0
- gitignore_cli/data/templates/jabref.gitignore +9 -0
- gitignore_cli/data/templates/janet.gitignore +11 -0
- gitignore_cli/data/templates/java.gitignore +30 -0
- gitignore_cli/data/templates/jboss-4-2-3-ga.gitignore +27 -0
- gitignore_cli/data/templates/jboss-6-x.gitignore +40 -0
- gitignore_cli/data/templates/jboss.gitignore +25 -0
- gitignore_cli/data/templates/jboss4.gitignore +25 -0
- gitignore_cli/data/templates/jboss6.gitignore +39 -0
- gitignore_cli/data/templates/jdeveloper.gitignore +19 -0
- gitignore_cli/data/templates/jekyll.gitignore +13 -0
- gitignore_cli/data/templates/jenv.gitignore +11 -0
- gitignore_cli/data/templates/jetbrains+all.gitignore +92 -0
- gitignore_cli/data/templates/jetbrains+iml.gitignore +91 -0
- gitignore_cli/data/templates/jetbrains.gitignore +117 -0
- gitignore_cli/data/templates/jgiven.gitignore +7 -0
- gitignore_cli/data/templates/jigsaw.gitignore +29 -0
- gitignore_cli/data/templates/jmeter.gitignore +17 -0
- gitignore_cli/data/templates/joe.gitignore +10 -0
- gitignore_cli/data/templates/joomla.gitignore +711 -0
- gitignore_cli/data/templates/jsonnet.gitignore +9 -0
- gitignore_cli/data/templates/jspm.gitignore +7 -0
- gitignore_cli/data/templates/julia.gitignore +30 -0
- gitignore_cli/data/templates/jupyternotebooks.gitignore +18 -0
- gitignore_cli/data/templates/justcode.gitignore +7 -0
- gitignore_cli/data/templates/kaldi.gitignore +8 -0
- gitignore_cli/data/templates/kate.gitignore +9 -0
- gitignore_cli/data/templates/kdevelop4.gitignore +8 -0
- gitignore_cli/data/templates/kdiff3.gitignore +16 -0
- gitignore_cli/data/templates/keil.gitignore +57 -0
- gitignore_cli/data/templates/kentico.gitignore +70 -0
- gitignore_cli/data/templates/keystonejs.gitignore +8 -0
- gitignore_cli/data/templates/kicad.gitignore +44 -0
- gitignore_cli/data/templates/kirby2.gitignore +21 -0
- gitignore_cli/data/templates/kirby3.gitignore +35 -0
- gitignore_cli/data/templates/kobalt.gitignore +9 -0
- gitignore_cli/data/templates/kohana.gitignore +8 -0
- gitignore_cli/data/templates/komodoedit.gitignore +8 -0
- gitignore_cli/data/templates/konyvisualizer.gitignore +126 -0
- gitignore_cli/data/templates/kotlin.gitignore +30 -0
- gitignore_cli/data/templates/labview.gitignore +23 -0
- gitignore_cli/data/templates/labviewnxg.gitignore +13 -0
- gitignore_cli/data/templates/lamp.gitignore +101 -0
- gitignore_cli/data/templates/laravel.gitignore +29 -0
- gitignore_cli/data/templates/latex.gitignore +314 -0
- gitignore_cli/data/templates/lazarus.gitignore +36 -0
- gitignore_cli/data/templates/leiningen.gitignore +20 -0
- gitignore_cli/data/templates/lemonstand.gitignore +27 -0
- gitignore_cli/data/templates/less.gitignore +7 -0
- gitignore_cli/data/templates/liberosoc.gitignore +32 -0
- gitignore_cli/data/templates/librarian-chef.gitignore +9 -0
- gitignore_cli/data/templates/libreoffice.gitignore +8 -0
- gitignore_cli/data/templates/lighthouseci.gitignore +8 -0
- gitignore_cli/data/templates/lilypond.gitignore +12 -0
- gitignore_cli/data/templates/linux.gitignore +19 -0
- gitignore_cli/data/templates/lithium.gitignore +8 -0
- gitignore_cli/data/templates/localstack.gitignore +8 -0
- gitignore_cli/data/templates/logtalk.gitignore +25 -0
- gitignore_cli/data/templates/lsspice.gitignore +8 -0
- gitignore_cli/data/templates/ltspice.gitignore +18 -0
- gitignore_cli/data/templates/lua.gitignore +47 -0
- gitignore_cli/data/templates/lyx.gitignore +10 -0
- gitignore_cli/data/templates/macos.gitignore +36 -0
- gitignore_cli/data/templates/magento.gitignore +55 -0
- gitignore_cli/data/templates/magento1.gitignore +51 -0
- gitignore_cli/data/templates/magento2.gitignore +76 -0
- gitignore_cli/data/templates/magic-xpa.gitignore +20 -0
- gitignore_cli/data/templates/matlab.gitignore +37 -0
- gitignore_cli/data/templates/maven.gitignore +23 -0
- gitignore_cli/data/templates/mavensmate.gitignore +22 -0
- gitignore_cli/data/templates/mdbook.gitignore +8 -0
- gitignore_cli/data/templates/mean.gitignore +169 -0
- gitignore_cli/data/templates/mercurial.gitignore +12 -0
- gitignore_cli/data/templates/mercury.gitignore +19 -0
- gitignore_cli/data/templates/meson.gitignore +27 -0
- gitignore_cli/data/templates/metals.gitignore +9 -0
- gitignore_cli/data/templates/metalsmith.gitignore +10 -0
- gitignore_cli/data/templates/metaprogrammingsystem.gitignore +22 -0
- gitignore_cli/data/templates/meteor.gitignore +18 -0
- gitignore_cli/data/templates/meteorjs.gitignore +17 -0
- gitignore_cli/data/templates/microsoftoffice.gitignore +25 -0
- gitignore_cli/data/templates/mikroc.gitignore +31 -0
- gitignore_cli/data/templates/mill.gitignore +7 -0
- gitignore_cli/data/templates/moban.gitignore +7 -0
- gitignore_cli/data/templates/modelsim.gitignore +29 -0
- gitignore_cli/data/templates/modx.gitignore +14 -0
- gitignore_cli/data/templates/momentics.gitignore +14 -0
- gitignore_cli/data/templates/monodevelop.gitignore +14 -0
- gitignore_cli/data/templates/mplabx.gitignore +38 -0
- gitignore_cli/data/templates/mule.gitignore +54 -0
- gitignore_cli/data/templates/nanoc.gitignore +16 -0
- gitignore_cli/data/templates/nativescript.gitignore +22 -0
- gitignore_cli/data/templates/ncrunch.gitignore +11 -0
- gitignore_cli/data/templates/nesc.gitignore +8 -0
- gitignore_cli/data/templates/netbeans.gitignore +14 -0
- gitignore_cli/data/templates/nette.gitignore +12 -0
- gitignore_cli/data/templates/nextjs.gitignore +40 -0
- gitignore_cli/data/templates/nikola.gitignore +13 -0
- gitignore_cli/data/templates/nim.gitignore +9 -0
- gitignore_cli/data/templates/ninja.gitignore +8 -0
- gitignore_cli/data/templates/node.gitignore +144 -0
- gitignore_cli/data/templates/nodechakratimetraveldebug.gitignore +12 -0
- gitignore_cli/data/templates/nohup.gitignore +7 -0
- gitignore_cli/data/templates/notepadpp.gitignore +8 -0
- gitignore_cli/data/templates/nova.gitignore +7 -0
- gitignore_cli/data/templates/now.gitignore +8 -0
- gitignore_cli/data/templates/nuxtjs.gitignore +18 -0
- gitignore_cli/data/templates/nwjs.gitignore +35 -0
- gitignore_cli/data/templates/objective-c.gitignore +70 -0
- gitignore_cli/data/templates/obsidian.gitignore +8 -0
- gitignore_cli/data/templates/ocaml.gitignore +35 -0
- gitignore_cli/data/templates/octave.gitignore +37 -0
- gitignore_cli/data/templates/octobercms.gitignore +25 -0
- gitignore_cli/data/templates/opa.gitignore +19 -0
- gitignore_cli/data/templates/opencart.gitignore +26 -0
- gitignore_cli/data/templates/opencv.gitignore +13 -0
- gitignore_cli/data/templates/openfoam.gitignore +61 -0
- gitignore_cli/data/templates/openframeworks+visualstudio.gitignore +91 -0
- gitignore_cli/data/templates/openframeworks.gitignore +79 -0
- gitignore_cli/data/templates/oracleforms.gitignore +14 -0
- gitignore_cli/data/templates/orcad.gitignore +8 -0
- gitignore_cli/data/templates/osx.gitignore +32 -0
- gitignore_cli/data/templates/otto.gitignore +7 -0
- gitignore_cli/data/templates/oxideshop.gitignore +28 -0
- gitignore_cli/data/templates/oxygenxmleditor.gitignore +9 -0
- gitignore_cli/data/templates/packer.gitignore +26 -0
- gitignore_cli/data/templates/pants.gitignore +10 -0
- gitignore_cli/data/templates/particle.gitignore +11 -0
- gitignore_cli/data/templates/patch.gitignore +8 -0
- gitignore_cli/data/templates/pawn.gitignore +19 -0
- gitignore_cli/data/templates/perl.gitignore +44 -0
- gitignore_cli/data/templates/perl6.gitignore +12 -0
- gitignore_cli/data/templates/ph7cms.gitignore +26 -0
- gitignore_cli/data/templates/phalcon.gitignore +8 -0
- gitignore_cli/data/templates/phoenix.gitignore +28 -0
- gitignore_cli/data/templates/php-cs-fixer.gitignore +14 -0
- gitignore_cli/data/templates/phpcodesniffer.gitignore +11 -0
- gitignore_cli/data/templates/phpstorm+all.gitignore +92 -0
- gitignore_cli/data/templates/phpstorm+iml.gitignore +91 -0
- gitignore_cli/data/templates/phpstorm.gitignore +117 -0
- gitignore_cli/data/templates/phpunit.gitignore +19 -0
- gitignore_cli/data/templates/pico8.gitignore +16 -0
- gitignore_cli/data/templates/pimcore.gitignore +59 -0
- gitignore_cli/data/templates/pimcore4.gitignore +57 -0
- gitignore_cli/data/templates/pimcore5.gitignore +24 -0
- gitignore_cli/data/templates/pinegrow.gitignore +11 -0
- gitignore_cli/data/templates/platformio.gitignore +11 -0
- gitignore_cli/data/templates/playframework.gitignore +22 -0
- gitignore_cli/data/templates/plone.gitignore +24 -0
- gitignore_cli/data/templates/polymer.gitignore +14 -0
- gitignore_cli/data/templates/powershell.gitignore +11 -0
- gitignore_cli/data/templates/premake-gmake.gitignore +9 -0
- gitignore_cli/data/templates/prepros.gitignore +10 -0
- gitignore_cli/data/templates/prestashop.gitignore +179 -0
- gitignore_cli/data/templates/processing.gitignore +16 -0
- gitignore_cli/data/templates/progressabl.gitignore +34 -0
- gitignore_cli/data/templates/psoccreator.gitignore +24 -0
- gitignore_cli/data/templates/pulumi+stacks.gitignore +16 -0
- gitignore_cli/data/templates/pulumi.gitignore +10 -0
- gitignore_cli/data/templates/puppet-librarian.gitignore +9 -0
- gitignore_cli/data/templates/puppet.gitignore +22 -0
- gitignore_cli/data/templates/purebasic.gitignore +22 -0
- gitignore_cli/data/templates/purescript.gitignore +15 -0
- gitignore_cli/data/templates/putty.gitignore +8 -0
- gitignore_cli/data/templates/pvs.gitignore +21 -0
- gitignore_cli/data/templates/pycharm+all.gitignore +92 -0
- gitignore_cli/data/templates/pycharm+iml.gitignore +91 -0
- gitignore_cli/data/templates/pycharm.gitignore +117 -0
- gitignore_cli/data/templates/pydev.gitignore +7 -0
- gitignore_cli/data/templates/python.gitignore +176 -0
- gitignore_cli/data/templates/pythonvanilla.gitignore +72 -0
- gitignore_cli/data/templates/qml.gitignore +9 -0
- gitignore_cli/data/templates/qooxdoo.gitignore +11 -0
- gitignore_cli/data/templates/qt.gitignore +60 -0
- gitignore_cli/data/templates/qtcreator.gitignore +37 -0
- gitignore_cli/data/templates/r.gitignore +59 -0
- gitignore_cli/data/templates/racket.gitignore +21 -0
- gitignore_cli/data/templates/rails.gitignore +75 -0
- gitignore_cli/data/templates/react.gitignore +20 -0
- gitignore_cli/data/templates/reactnative.gitignore +256 -0
- gitignore_cli/data/templates/reasonml.gitignore +7 -0
- gitignore_cli/data/templates/red.gitignore +22 -0
- gitignore_cli/data/templates/redcar.gitignore +7 -0
- gitignore_cli/data/templates/redis.gitignore +9 -0
- gitignore_cli/data/templates/remix+arc.gitignore +10 -0
- gitignore_cli/data/templates/remix+cloudflarepages.gitignore +8 -0
- gitignore_cli/data/templates/remix+cloudflareworkers.gitignore +8 -0
- gitignore_cli/data/templates/remix+netlify.gitignore +7 -0
- gitignore_cli/data/templates/remix+vercel.gitignore +10 -0
- gitignore_cli/data/templates/remix.gitignore +11 -0
- gitignore_cli/data/templates/renpy.gitignore +31 -0
- gitignore_cli/data/templates/replit.gitignore +11 -0
- gitignore_cli/data/templates/retool.gitignore +7 -0
- gitignore_cli/data/templates/rhodesrhomobile.gitignore +15 -0
- gitignore_cli/data/templates/rider.gitignore +83 -0
- gitignore_cli/data/templates/robotframework.gitignore +10 -0
- gitignore_cli/data/templates/root.gitignore +17 -0
- gitignore_cli/data/templates/ros.gitignore +57 -0
- gitignore_cli/data/templates/ros2.gitignore +35 -0
- gitignore_cli/data/templates/ruby.gitignore +61 -0
- gitignore_cli/data/templates/rubymine+all.gitignore +92 -0
- gitignore_cli/data/templates/rubymine+iml.gitignore +91 -0
- gitignore_cli/data/templates/rubymine.gitignore +117 -0
- gitignore_cli/data/templates/rust-analyzer.gitignore +9 -0
- gitignore_cli/data/templates/rust.gitignore +20 -0
- gitignore_cli/data/templates/salesforce.gitignore +59 -0
- gitignore_cli/data/templates/salesforcedx.gitignore +62 -0
- gitignore_cli/data/templates/sam+config.gitignore +15 -0
- gitignore_cli/data/templates/sam.gitignore +11 -0
- gitignore_cli/data/templates/sas.gitignore +20 -0
- gitignore_cli/data/templates/sass.gitignore +10 -0
- gitignore_cli/data/templates/sbt.gitignore +21 -0
- gitignore_cli/data/templates/scala.gitignore +11 -0
- gitignore_cli/data/templates/scheme.gitignore +13 -0
- gitignore_cli/data/templates/scons.gitignore +12 -0
- gitignore_cli/data/templates/scrivener.gitignore +14 -0
- gitignore_cli/data/templates/sdcc.gitignore +14 -0
- gitignore_cli/data/templates/seamgen.gitignore +32 -0
- gitignore_cli/data/templates/senchatouch.gitignore +12 -0
- gitignore_cli/data/templates/serverless.gitignore +8 -0
- gitignore_cli/data/templates/shopware.gitignore +50 -0
- gitignore_cli/data/templates/silverstripe.gitignore +15 -0
- gitignore_cli/data/templates/sketchup.gitignore +7 -0
- gitignore_cli/data/templates/slickedit.gitignore +17 -0
- gitignore_cli/data/templates/smalltalk.gitignore +37 -0
- gitignore_cli/data/templates/snap.gitignore +20 -0
- gitignore_cli/data/templates/snapcraft.gitignore +17 -0
- gitignore_cli/data/templates/snyk.gitignore +8 -0
- gitignore_cli/data/templates/solidity.gitignore +135 -0
- gitignore_cli/data/templates/soliditytruffle.gitignore +30 -0
- gitignore_cli/data/templates/sonar.gitignore +8 -0
- gitignore_cli/data/templates/sonarqube.gitignore +17 -0
- gitignore_cli/data/templates/sourcepawn.gitignore +10 -0
- gitignore_cli/data/templates/spark.gitignore +106 -0
- gitignore_cli/data/templates/specflow.gitignore +9 -0
- gitignore_cli/data/templates/splunk.gitignore +14 -0
- gitignore_cli/data/templates/spreadsheet.gitignore +9 -0
- gitignore_cli/data/templates/ssh.gitignore +9 -0
- gitignore_cli/data/templates/standardml.gitignore +8 -0
- gitignore_cli/data/templates/stata.gitignore +30 -0
- gitignore_cli/data/templates/stdlib.gitignore +8 -0
- gitignore_cli/data/templates/stella.gitignore +18 -0
- gitignore_cli/data/templates/stellar.gitignore +7 -0
- gitignore_cli/data/templates/storybookjs.gitignore +10 -0
- gitignore_cli/data/templates/strapi.gitignore +100 -0
- gitignore_cli/data/templates/stylus.gitignore +7 -0
- gitignore_cli/data/templates/sublimetext.gitignore +37 -0
- gitignore_cli/data/templates/sugarcrm.gitignore +33 -0
- gitignore_cli/data/templates/svelte.gitignore +11 -0
- gitignore_cli/data/templates/svn.gitignore +7 -0
- gitignore_cli/data/templates/swift.gitignore +88 -0
- gitignore_cli/data/templates/swiftpackagemanager.gitignore +12 -0
- gitignore_cli/data/templates/swiftpm.gitignore +12 -0
- gitignore_cli/data/templates/symfony.gitignore +62 -0
- gitignore_cli/data/templates/symphonycms.gitignore +12 -0
- gitignore_cli/data/templates/synology.gitignore +10 -0
- gitignore_cli/data/templates/synopsysvcs.gitignore +42 -0
- gitignore_cli/data/templates/tags.gitignore +23 -0
- gitignore_cli/data/templates/tarmainstallmate.gitignore +12 -0
- gitignore_cli/data/templates/terraform.gitignore +40 -0
- gitignore_cli/data/templates/terragrunt.gitignore +12 -0
- gitignore_cli/data/templates/test.gitignore +84 -0
- gitignore_cli/data/templates/testcomplete.gitignore +20 -0
- gitignore_cli/data/templates/testinfra.gitignore +8 -0
- gitignore_cli/data/templates/tex.gitignore +314 -0
- gitignore_cli/data/templates/text.gitignore +15 -0
- gitignore_cli/data/templates/textmate.gitignore +9 -0
- gitignore_cli/data/templates/textpattern.gitignore +17 -0
- gitignore_cli/data/templates/theos-tweak.gitignore +13 -0
- gitignore_cli/data/templates/thinkphp.gitignore +14 -0
- gitignore_cli/data/templates/tla+.gitignore +35 -0
- gitignore_cli/data/templates/toit.gitignore +8 -0
- gitignore_cli/data/templates/tortoisegit.gitignore +8 -0
- gitignore_cli/data/templates/tower.gitignore +8 -0
- gitignore_cli/data/templates/turbo.gitignore +8 -0
- gitignore_cli/data/templates/turbogears2.gitignore +26 -0
- gitignore_cli/data/templates/twincat3.gitignore +54 -0
- gitignore_cli/data/templates/tye.gitignore +8 -0
- gitignore_cli/data/templates/typings.gitignore +8 -0
- gitignore_cli/data/templates/typo3-composer.gitignore +19 -0
- gitignore_cli/data/templates/typo3.gitignore +29 -0
- gitignore_cli/data/templates/umbraco.gitignore +57 -0
- gitignore_cli/data/templates/unity.gitignore +77 -0
- gitignore_cli/data/templates/unrealengine.gitignore +96 -0
- gitignore_cli/data/templates/vaadin.gitignore +8 -0
- gitignore_cli/data/templates/vagrant.gitignore +14 -0
- gitignore_cli/data/templates/valgrind.gitignore +23 -0
- gitignore_cli/data/templates/vapor.gitignore +15 -0
- gitignore_cli/data/templates/vcpkg.gitignore +12 -0
- gitignore_cli/data/templates/venv.gitignore +18 -0
- gitignore_cli/data/templates/vercel.gitignore +7 -0
- gitignore_cli/data/templates/vertx.gitignore +8 -0
- gitignore_cli/data/templates/video.gitignore +22 -0
- gitignore_cli/data/templates/vim.gitignore +25 -0
- gitignore_cli/data/templates/virtualenv.gitignore +18 -0
- gitignore_cli/data/templates/virtuoso.gitignore +24 -0
- gitignore_cli/data/templates/visualbasic.gitignore +70 -0
- gitignore_cli/data/templates/visualstudio.gitignore +405 -0
- gitignore_cli/data/templates/visualstudiocode.gitignore +23 -0
- gitignore_cli/data/templates/vivado.gitignore +71 -0
- gitignore_cli/data/templates/vlab.gitignore +43 -0
- gitignore_cli/data/templates/vrealizeorchestrator.gitignore +29 -0
- gitignore_cli/data/templates/vs.gitignore +359 -0
- gitignore_cli/data/templates/vue.gitignore +15 -0
- gitignore_cli/data/templates/vuejs.gitignore +12 -0
- gitignore_cli/data/templates/vvvv.gitignore +12 -0
- gitignore_cli/data/templates/waf.gitignore +15 -0
- gitignore_cli/data/templates/wakanda.gitignore +33 -0
- gitignore_cli/data/templates/web.gitignore +19 -0
- gitignore_cli/data/templates/webmethods.gitignore +20 -0
- gitignore_cli/data/templates/webstorm+all.gitignore +92 -0
- gitignore_cli/data/templates/webstorm+iml.gitignore +91 -0
- gitignore_cli/data/templates/webstorm.gitignore +117 -0
- gitignore_cli/data/templates/werckercli.gitignore +10 -0
- gitignore_cli/data/templates/windows.gitignore +30 -0
- gitignore_cli/data/templates/wintersmith.gitignore +13 -0
- gitignore_cli/data/templates/wordpress.gitignore +50 -0
- gitignore_cli/data/templates/wyam.gitignore +11 -0
- gitignore_cli/data/templates/xamarinstudio.gitignore +10 -0
- gitignore_cli/data/templates/xcode.gitignore +21 -0
- gitignore_cli/data/templates/xcodeinjection.gitignore +12 -0
- gitignore_cli/data/templates/xilinx.gitignore +111 -0
- gitignore_cli/data/templates/xilinxise.gitignore +73 -0
- gitignore_cli/data/templates/xilinxvivado.gitignore +65 -0
- gitignore_cli/data/templates/xill.gitignore +12 -0
- gitignore_cli/data/templates/xmake.gitignore +9 -0
- gitignore_cli/data/templates/xojo.gitignore +17 -0
- gitignore_cli/data/templates/xtext.gitignore +13 -0
- gitignore_cli/data/templates/y86.gitignore +8 -0
- gitignore_cli/data/templates/yalc.gitignore +11 -0
- gitignore_cli/data/templates/yarn.gitignore +21 -0
- gitignore_cli/data/templates/yeoman.gitignore +12 -0
- gitignore_cli/data/templates/yii.gitignore +12 -0
- gitignore_cli/data/templates/yii2.gitignore +49 -0
- gitignore_cli/data/templates/zendframework.gitignore +30 -0
- gitignore_cli/data/templates/zephir.gitignore +32 -0
- gitignore_cli/data/templates/zig.gitignore +13 -0
- gitignore_cli/data/templates/zsh.gitignore +40 -0
- gitignore_cli/data/templates/zukencr8000.gitignore +82 -0
- gitignore_cli/deps.py +106 -0
- gitignore_cli/detect.py +247 -0
- gitignore_cli/file.py +137 -0
- gitignore_cli/hooks.py +182 -0
- gitignore_cli/ignored_dirs.py +100 -0
- gitignore_cli/mapping.py +109 -0
- gitignore_cli/templates.py +163 -0
- gitignorio_cli-0.1.0.dist-info/METADATA +77 -0
- gitignorio_cli-0.1.0.dist-info/RECORD +588 -0
- gitignorio_cli-0.1.0.dist-info/WHEEL +4 -0
- gitignorio_cli-0.1.0.dist-info/entry_points.txt +2 -0
- gitignorio_cli-0.1.0.dist-info/licenses/LICENSE.md +9 -0
gitignore_cli/file.py
ADDED
|
@@ -0,0 +1,137 @@
|
|
|
1
|
+
from __future__ import annotations
|
|
2
|
+
|
|
3
|
+
from dataclasses import dataclass, field
|
|
4
|
+
from pathlib import Path
|
|
5
|
+
|
|
6
|
+
from gitignore_cli.mapping import OS_TEMPLATES
|
|
7
|
+
from gitignore_cli.templates import (
|
|
8
|
+
CREATED_LINE,
|
|
9
|
+
EDIT_LINE,
|
|
10
|
+
END_LINE,
|
|
11
|
+
SECTION_HEADER,
|
|
12
|
+
TemplateStore,
|
|
13
|
+
)
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
@dataclass
|
|
17
|
+
class GitignoreFile:
|
|
18
|
+
path: Path
|
|
19
|
+
templates: list[str] = field(default_factory=list)
|
|
20
|
+
sections: dict[str, str] = field(default_factory=dict)
|
|
21
|
+
preamble: str = ""
|
|
22
|
+
managed: bool = False
|
|
23
|
+
|
|
24
|
+
@classmethod
|
|
25
|
+
def load(cls, path: Path, store: TemplateStore) -> GitignoreFile:
|
|
26
|
+
if not path.exists():
|
|
27
|
+
return cls(path=path)
|
|
28
|
+
|
|
29
|
+
content = path.read_text(encoding="utf-8")
|
|
30
|
+
parsed = cls(path=path)
|
|
31
|
+
created = CREATED_LINE.search(content)
|
|
32
|
+
edited = EDIT_LINE.search(content)
|
|
33
|
+
parsed.managed = bool(created or edited)
|
|
34
|
+
|
|
35
|
+
if created:
|
|
36
|
+
parsed.templates = [part.strip().lower() for part in created.group(1).split(",") if part.strip()]
|
|
37
|
+
elif edited:
|
|
38
|
+
parsed.templates = [part.strip().lower() for part in edited.group(1).split(",") if part.strip()]
|
|
39
|
+
|
|
40
|
+
end_match = END_LINE.search(content)
|
|
41
|
+
body = content[: end_match.start()] if end_match else content
|
|
42
|
+
|
|
43
|
+
if parsed.managed:
|
|
44
|
+
first_section = SECTION_HEADER.search(body)
|
|
45
|
+
parsed.preamble = body[: first_section.start()].strip() if first_section else body.strip()
|
|
46
|
+
for title, section in store.extract_sections(body):
|
|
47
|
+
template = store.title_to_template(title, candidates=parsed.templates)
|
|
48
|
+
key = template or title.lower()
|
|
49
|
+
parsed.sections[key] = section
|
|
50
|
+
else:
|
|
51
|
+
parsed.preamble = content.strip()
|
|
52
|
+
|
|
53
|
+
return parsed
|
|
54
|
+
|
|
55
|
+
def has_template(self, template: str) -> bool:
|
|
56
|
+
template = template.lower()
|
|
57
|
+
return template in self.templates or template in self.sections
|
|
58
|
+
|
|
59
|
+
def template_present(self, store: TemplateStore, template: str, content: str | None = None) -> bool:
|
|
60
|
+
template = template.lower()
|
|
61
|
+
if self.has_template(template):
|
|
62
|
+
return True
|
|
63
|
+
if content is None:
|
|
64
|
+
content = self.path.read_text(encoding="utf-8") if self.path.exists() else ""
|
|
65
|
+
if not content:
|
|
66
|
+
return False
|
|
67
|
+
title = store.section_title(template)
|
|
68
|
+
return f"### {title} ###" in content
|
|
69
|
+
|
|
70
|
+
def os_templates(self) -> list[str]:
|
|
71
|
+
return [template for template in self.templates if template in OS_TEMPLATES]
|
|
72
|
+
|
|
73
|
+
def language_templates(self) -> list[str]:
|
|
74
|
+
return [template for template in self.templates if template not in OS_TEMPLATES]
|
|
75
|
+
|
|
76
|
+
def render(self, store: TemplateStore, templates: list[str]) -> str:
|
|
77
|
+
ordered = store.sort_templates(templates)
|
|
78
|
+
if not ordered:
|
|
79
|
+
return ""
|
|
80
|
+
|
|
81
|
+
if not self.managed and self.preamble and not self.sections:
|
|
82
|
+
joined = ",".join(ordered)
|
|
83
|
+
appended = store.build_document(ordered)
|
|
84
|
+
return f"{self.preamble.rstrip()}\n\n{appended.rstrip()}\n"
|
|
85
|
+
|
|
86
|
+
joined = ",".join(ordered)
|
|
87
|
+
header = (
|
|
88
|
+
f"# Created by https://www.toptal.com/developers/gitignore/api/{joined}\n"
|
|
89
|
+
f"# Edit at https://www.toptal.com/developers/gitignore?templates={joined}\n"
|
|
90
|
+
)
|
|
91
|
+
sections: list[str] = []
|
|
92
|
+
for template in ordered:
|
|
93
|
+
if template in self.sections:
|
|
94
|
+
sections.append(self.sections[template].strip())
|
|
95
|
+
else:
|
|
96
|
+
sections.append(store.section_for_template(template).strip())
|
|
97
|
+
|
|
98
|
+
body = "\n\n".join(section for section in sections if section)
|
|
99
|
+
footer = f"# End of https://www.toptal.com/developers/gitignore/api/{joined}\n"
|
|
100
|
+
return f"{header}\n{body.rstrip()}\n\n{footer}"
|
|
101
|
+
|
|
102
|
+
def write(self, store: TemplateStore, templates: list[str]) -> None:
|
|
103
|
+
content = self.render(store, templates)
|
|
104
|
+
self.path.write_text(content, encoding="utf-8")
|
|
105
|
+
|
|
106
|
+
def add_template(self, store: TemplateStore, template: str) -> bool:
|
|
107
|
+
template = template.lower()
|
|
108
|
+
if self.has_template(template):
|
|
109
|
+
return False
|
|
110
|
+
|
|
111
|
+
self.templates.append(template)
|
|
112
|
+
self.sections[template] = store.section_for_template(template)
|
|
113
|
+
self.managed = True
|
|
114
|
+
return True
|
|
115
|
+
|
|
116
|
+
def append_templates(self, store: TemplateStore, templates: list[str]) -> list[str]:
|
|
117
|
+
"""Append template sections without rewriting existing file content."""
|
|
118
|
+
content = self.path.read_text(encoding="utf-8") if self.path.exists() else ""
|
|
119
|
+
added: list[str] = []
|
|
120
|
+
|
|
121
|
+
for template in store.sort_templates(templates):
|
|
122
|
+
if self.template_present(store, template, content):
|
|
123
|
+
continue
|
|
124
|
+
section = store.section_for_template(template).strip()
|
|
125
|
+
if content and not content.endswith("\n"):
|
|
126
|
+
content += "\n"
|
|
127
|
+
if content.strip():
|
|
128
|
+
content += "\n"
|
|
129
|
+
content += section + "\n"
|
|
130
|
+
added.append(template)
|
|
131
|
+
if template not in self.templates:
|
|
132
|
+
self.templates.append(template)
|
|
133
|
+
self.sections[template] = section
|
|
134
|
+
|
|
135
|
+
if added:
|
|
136
|
+
self.path.write_text(content, encoding="utf-8")
|
|
137
|
+
return added
|
gitignore_cli/hooks.py
ADDED
|
@@ -0,0 +1,182 @@
|
|
|
1
|
+
from __future__ import annotations
|
|
2
|
+
|
|
3
|
+
import os
|
|
4
|
+
import subprocess
|
|
5
|
+
from dataclasses import dataclass
|
|
6
|
+
from pathlib import Path
|
|
7
|
+
|
|
8
|
+
from gitignore_cli.deps import ensure_detection_tools
|
|
9
|
+
from gitignore_cli.detect import detect_languages, detect_os_template
|
|
10
|
+
from gitignore_cli.file import GitignoreFile
|
|
11
|
+
from gitignore_cli.templates import get_store
|
|
12
|
+
|
|
13
|
+
MARKER = "# Managed by gitignore-cli"
|
|
14
|
+
TEMPLATE_DIR_NAME = "gitignore-cli"
|
|
15
|
+
|
|
16
|
+
POST_CHECKOUT_HOOK = "post-checkout"
|
|
17
|
+
PRE_PUSH_HOOK = "pre-push"
|
|
18
|
+
|
|
19
|
+
INIT_BODY = """\
|
|
20
|
+
# Create .gitignore when a repository is initialized (clone/checkout).
|
|
21
|
+
root="$(git rev-parse --show-toplevel 2>/dev/null)" || exit 0
|
|
22
|
+
if [ ! -f "$root/.gitignore" ]; then
|
|
23
|
+
gi create --path "$root" 2>/dev/null || true
|
|
24
|
+
fi
|
|
25
|
+
"""
|
|
26
|
+
|
|
27
|
+
SYNC_BODY = """\
|
|
28
|
+
# Sync .gitignore before pushing (update if present, create if missing).
|
|
29
|
+
root="$(git rev-parse --show-toplevel 2>/dev/null)" || exit 0
|
|
30
|
+
if [ -f "$root/.gitignore" ]; then
|
|
31
|
+
gi update --path "$root" 2>/dev/null || true
|
|
32
|
+
else
|
|
33
|
+
gi create --path "$root" 2>/dev/null || true
|
|
34
|
+
fi
|
|
35
|
+
"""
|
|
36
|
+
|
|
37
|
+
|
|
38
|
+
@dataclass(frozen=True)
|
|
39
|
+
class HookSpec:
|
|
40
|
+
name: str
|
|
41
|
+
body: str
|
|
42
|
+
run_on_install: bool = False
|
|
43
|
+
|
|
44
|
+
|
|
45
|
+
HOOKS = (
|
|
46
|
+
HookSpec(POST_CHECKOUT_HOOK, INIT_BODY, run_on_install=True),
|
|
47
|
+
HookSpec(PRE_PUSH_HOOK, SYNC_BODY),
|
|
48
|
+
)
|
|
49
|
+
|
|
50
|
+
|
|
51
|
+
def ensure_gitignore(repo_path: Path) -> bool:
|
|
52
|
+
"""Create .gitignore when it is missing. Returns True if a file was created."""
|
|
53
|
+
gitignore_path = repo_path / ".gitignore"
|
|
54
|
+
if gitignore_path.exists():
|
|
55
|
+
return False
|
|
56
|
+
|
|
57
|
+
ensure_detection_tools()
|
|
58
|
+
store = get_store()
|
|
59
|
+
os_template = detect_os_template()
|
|
60
|
+
detected = detect_languages(repo_path, store)
|
|
61
|
+
templates = [os_template, *sorted(detected)]
|
|
62
|
+
document = GitignoreFile(path=gitignore_path)
|
|
63
|
+
document.write(store, store.sort_templates(templates))
|
|
64
|
+
return True
|
|
65
|
+
|
|
66
|
+
|
|
67
|
+
def sync_gitignore(repo_path: Path) -> None:
|
|
68
|
+
"""Update .gitignore when present, otherwise create it."""
|
|
69
|
+
gitignore_path = repo_path / ".gitignore"
|
|
70
|
+
if not gitignore_path.exists():
|
|
71
|
+
ensure_gitignore(repo_path)
|
|
72
|
+
return
|
|
73
|
+
|
|
74
|
+
ensure_detection_tools()
|
|
75
|
+
store = get_store()
|
|
76
|
+
os_template = detect_os_template()
|
|
77
|
+
document = GitignoreFile.load(gitignore_path, store)
|
|
78
|
+
detected = detect_languages(repo_path, store)
|
|
79
|
+
content = gitignore_path.read_text(encoding="utf-8")
|
|
80
|
+
|
|
81
|
+
to_add: list[str] = []
|
|
82
|
+
if not document.template_present(store, os_template, content):
|
|
83
|
+
to_add.append(os_template)
|
|
84
|
+
for template in sorted(detected):
|
|
85
|
+
if not document.template_present(store, template, content):
|
|
86
|
+
to_add.append(template)
|
|
87
|
+
|
|
88
|
+
document.append_templates(store, to_add)
|
|
89
|
+
|
|
90
|
+
|
|
91
|
+
def find_git_dir(repo_path: Path) -> Path | None:
|
|
92
|
+
result = subprocess.run(
|
|
93
|
+
["git", "-C", str(repo_path), "rev-parse", "--git-dir"],
|
|
94
|
+
capture_output=True,
|
|
95
|
+
text=True,
|
|
96
|
+
check=False,
|
|
97
|
+
)
|
|
98
|
+
if result.returncode != 0:
|
|
99
|
+
return None
|
|
100
|
+
|
|
101
|
+
git_dir = Path(result.stdout.strip())
|
|
102
|
+
if not git_dir.is_absolute():
|
|
103
|
+
git_dir = (repo_path / git_dir).resolve()
|
|
104
|
+
return git_dir
|
|
105
|
+
|
|
106
|
+
|
|
107
|
+
def hooks_dir(repo_path: Path) -> Path | None:
|
|
108
|
+
git_dir = find_git_dir(repo_path)
|
|
109
|
+
if git_dir is None:
|
|
110
|
+
return None
|
|
111
|
+
return git_dir / "hooks"
|
|
112
|
+
|
|
113
|
+
|
|
114
|
+
def global_template_dir() -> Path:
|
|
115
|
+
xdg_config = os.environ.get("XDG_CONFIG_HOME")
|
|
116
|
+
config_root = Path(xdg_config) if xdg_config else Path.home() / ".config"
|
|
117
|
+
return config_root / TEMPLATE_DIR_NAME / "template"
|
|
118
|
+
|
|
119
|
+
|
|
120
|
+
def _render_hook(spec: HookSpec) -> str:
|
|
121
|
+
return f"#!/bin/sh\n{MARKER}\n{spec.body}"
|
|
122
|
+
|
|
123
|
+
|
|
124
|
+
def _append_block(spec: HookSpec) -> str:
|
|
125
|
+
return f"\n# --- gitignore-cli: {spec.name} ---\n{MARKER}\n{spec.body}"
|
|
126
|
+
|
|
127
|
+
|
|
128
|
+
def install_hook_file(path: Path, spec: HookSpec) -> str:
|
|
129
|
+
rendered = _render_hook(spec)
|
|
130
|
+
if not path.exists():
|
|
131
|
+
path.write_text(rendered, encoding="utf-8")
|
|
132
|
+
path.chmod(0o755)
|
|
133
|
+
return "installed"
|
|
134
|
+
|
|
135
|
+
existing = path.read_text(encoding="utf-8")
|
|
136
|
+
if MARKER in existing:
|
|
137
|
+
path.write_text(rendered, encoding="utf-8")
|
|
138
|
+
path.chmod(0o755)
|
|
139
|
+
return "updated"
|
|
140
|
+
|
|
141
|
+
path.write_text(existing.rstrip() + _append_block(spec) + "\n", encoding="utf-8")
|
|
142
|
+
path.chmod(0o755)
|
|
143
|
+
return "appended"
|
|
144
|
+
|
|
145
|
+
|
|
146
|
+
def run_hook_body(spec: HookSpec, repo_path: Path) -> None:
|
|
147
|
+
if spec.name == POST_CHECKOUT_HOOK:
|
|
148
|
+
ensure_gitignore(repo_path)
|
|
149
|
+
return
|
|
150
|
+
|
|
151
|
+
sync_gitignore(repo_path)
|
|
152
|
+
|
|
153
|
+
|
|
154
|
+
def install_repo_hooks(repo_path: Path) -> list[tuple[str, str]]:
|
|
155
|
+
target = hooks_dir(repo_path)
|
|
156
|
+
if target is None:
|
|
157
|
+
raise RuntimeError(f"{repo_path} is not inside a git repository.")
|
|
158
|
+
|
|
159
|
+
results: list[tuple[str, str]] = []
|
|
160
|
+
for spec in HOOKS:
|
|
161
|
+
status = install_hook_file(target / spec.name, spec)
|
|
162
|
+
results.append((spec.name, status))
|
|
163
|
+
if spec.run_on_install:
|
|
164
|
+
run_hook_body(spec, repo_path)
|
|
165
|
+
return results
|
|
166
|
+
|
|
167
|
+
|
|
168
|
+
def install_global_template() -> Path:
|
|
169
|
+
template_root = global_template_dir()
|
|
170
|
+
hooks_target = template_root / "hooks"
|
|
171
|
+
hooks_target.mkdir(parents=True, exist_ok=True)
|
|
172
|
+
|
|
173
|
+
for spec in HOOKS:
|
|
174
|
+
path = hooks_target / spec.name
|
|
175
|
+
path.write_text(_render_hook(spec), encoding="utf-8")
|
|
176
|
+
path.chmod(0o755)
|
|
177
|
+
|
|
178
|
+
subprocess.run(
|
|
179
|
+
["git", "config", "--global", "init.templateDir", str(template_root)],
|
|
180
|
+
check=True,
|
|
181
|
+
)
|
|
182
|
+
return template_root
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
"""Directory names skipped during language detection.
|
|
2
|
+
|
|
3
|
+
Any path component matching one of these names (case-insensitively) is not
|
|
4
|
+
walked or scanned. Covers third-party dependencies, package caches, and common
|
|
5
|
+
build output directories across languages and frameworks.
|
|
6
|
+
"""
|
|
7
|
+
|
|
8
|
+
from __future__ import annotations
|
|
9
|
+
|
|
10
|
+
from pathlib import Path
|
|
11
|
+
|
|
12
|
+
# Stored lowercase; matched case-insensitively against each path component.
|
|
13
|
+
IGNORED_DIRS = frozenset(
|
|
14
|
+
{
|
|
15
|
+
# Version control
|
|
16
|
+
".git",
|
|
17
|
+
".hg",
|
|
18
|
+
".svn",
|
|
19
|
+
# Python
|
|
20
|
+
"__pycache__",
|
|
21
|
+
".eggs",
|
|
22
|
+
".hypothesis",
|
|
23
|
+
".mypy_cache",
|
|
24
|
+
".nox",
|
|
25
|
+
".pytest_cache",
|
|
26
|
+
".ruff_cache",
|
|
27
|
+
".tox",
|
|
28
|
+
".venv",
|
|
29
|
+
"env",
|
|
30
|
+
"site-packages",
|
|
31
|
+
"venv",
|
|
32
|
+
# JavaScript / Node / front-end package managers
|
|
33
|
+
".pnp",
|
|
34
|
+
".yarn",
|
|
35
|
+
"bower_components",
|
|
36
|
+
"jspm_packages",
|
|
37
|
+
"node_modules",
|
|
38
|
+
# PHP / Ruby / Composer / Bundler
|
|
39
|
+
".bundle",
|
|
40
|
+
"vendor",
|
|
41
|
+
"vendors",
|
|
42
|
+
# Java / JVM / Android
|
|
43
|
+
".gradle",
|
|
44
|
+
".ivy2",
|
|
45
|
+
".m2",
|
|
46
|
+
".sbt",
|
|
47
|
+
"target",
|
|
48
|
+
# .NET / NuGet
|
|
49
|
+
".nuget",
|
|
50
|
+
"packages",
|
|
51
|
+
# Go
|
|
52
|
+
"godeps",
|
|
53
|
+
# Rust / Cargo (target covered above)
|
|
54
|
+
# Elixir / Erlang / Phoenix
|
|
55
|
+
"_build",
|
|
56
|
+
"_checkouts",
|
|
57
|
+
"deps",
|
|
58
|
+
# Haskell / Stack
|
|
59
|
+
".stack-work",
|
|
60
|
+
# Swift / iOS / CocoaPods / Carthage / Xcode
|
|
61
|
+
"carthage",
|
|
62
|
+
"deriveddata",
|
|
63
|
+
"deriveddatacache",
|
|
64
|
+
"pods",
|
|
65
|
+
# C / C++ / cross-language vendoring conventions
|
|
66
|
+
"3rdparty",
|
|
67
|
+
"dependencies",
|
|
68
|
+
"external",
|
|
69
|
+
"externals",
|
|
70
|
+
"third-party",
|
|
71
|
+
"third_party",
|
|
72
|
+
# Dart / Flutter
|
|
73
|
+
".dart_tool",
|
|
74
|
+
".pub-cache",
|
|
75
|
+
# Scala / Metals / Bloop
|
|
76
|
+
".bloop",
|
|
77
|
+
".metals",
|
|
78
|
+
# Zig
|
|
79
|
+
"zig-cache",
|
|
80
|
+
"zig-out",
|
|
81
|
+
# Unity / game engines (generated local package cache)
|
|
82
|
+
"library",
|
|
83
|
+
# Other dependency layouts
|
|
84
|
+
"_esy",
|
|
85
|
+
"_vendor",
|
|
86
|
+
"xvba_modules",
|
|
87
|
+
# Common build / distribution output
|
|
88
|
+
"build",
|
|
89
|
+
"dist",
|
|
90
|
+
"out",
|
|
91
|
+
}
|
|
92
|
+
)
|
|
93
|
+
|
|
94
|
+
|
|
95
|
+
def dir_name_is_ignored(name: str) -> bool:
|
|
96
|
+
return name.lower() in IGNORED_DIRS
|
|
97
|
+
|
|
98
|
+
|
|
99
|
+
def path_is_ignored(path: Path | str) -> bool:
|
|
100
|
+
return any(dir_name_is_ignored(part) for part in Path(path).parts)
|
gitignore_cli/mapping.py
ADDED
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
from __future__ import annotations
|
|
2
|
+
|
|
3
|
+
import re
|
|
4
|
+
|
|
5
|
+
# Linguist language names and magika labels mapped to gitignore.io template keys.
|
|
6
|
+
LANGUAGE_ALIASES: dict[str, str] = {
|
|
7
|
+
"c#": "csharp",
|
|
8
|
+
"c++": "c++",
|
|
9
|
+
"clojure": "clojure",
|
|
10
|
+
"common lisp": "commonlisp",
|
|
11
|
+
"crystal": "crystal",
|
|
12
|
+
"css": "web",
|
|
13
|
+
"dart": "dart",
|
|
14
|
+
"elixir": "elixir",
|
|
15
|
+
"elm": "elm",
|
|
16
|
+
"erlang": "erlang",
|
|
17
|
+
"f#": "fsharp",
|
|
18
|
+
"fortran": "fortran",
|
|
19
|
+
"go": "go",
|
|
20
|
+
"groovy": "groovy",
|
|
21
|
+
"haskell": "haskell",
|
|
22
|
+
"html": "web",
|
|
23
|
+
"java": "java",
|
|
24
|
+
"javascript": "node",
|
|
25
|
+
"js": "node",
|
|
26
|
+
"jsonnet": "jsonnet",
|
|
27
|
+
"julia": "julia",
|
|
28
|
+
"kotlin": "kotlin",
|
|
29
|
+
"less": "less",
|
|
30
|
+
"lua": "lua",
|
|
31
|
+
"makefile": "cmake",
|
|
32
|
+
"nim": "nim",
|
|
33
|
+
"objective-c": "objective-c",
|
|
34
|
+
"ocaml": "ocaml",
|
|
35
|
+
"perl": "perl",
|
|
36
|
+
"php": "composer",
|
|
37
|
+
"powershell": "powershell",
|
|
38
|
+
"python": "python",
|
|
39
|
+
"r": "r",
|
|
40
|
+
"ruby": "ruby",
|
|
41
|
+
"rust": "rust",
|
|
42
|
+
"scala": "scala",
|
|
43
|
+
"scheme": "scheme",
|
|
44
|
+
"solidity": "solidity",
|
|
45
|
+
"sql": "database",
|
|
46
|
+
"svelte": "svelte",
|
|
47
|
+
"swift": "swift",
|
|
48
|
+
"typescript": "node",
|
|
49
|
+
"tsx": "node",
|
|
50
|
+
"tsxreact": "react",
|
|
51
|
+
"vue": "vue",
|
|
52
|
+
"zig": "zig",
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
OS_TEMPLATES = frozenset({"linux", "macos", "osx", "windows"})
|
|
56
|
+
|
|
57
|
+
SKIP_MAGIKA_LABELS = frozenset(
|
|
58
|
+
{
|
|
59
|
+
"asm",
|
|
60
|
+
"batch",
|
|
61
|
+
"binary",
|
|
62
|
+
"csv",
|
|
63
|
+
"doc",
|
|
64
|
+
"docx",
|
|
65
|
+
"email",
|
|
66
|
+
"ignorefile",
|
|
67
|
+
"ini",
|
|
68
|
+
"json",
|
|
69
|
+
"markdown",
|
|
70
|
+
"pdf",
|
|
71
|
+
"pem",
|
|
72
|
+
"pptx",
|
|
73
|
+
"rtf",
|
|
74
|
+
"shell",
|
|
75
|
+
"svg",
|
|
76
|
+
"toml",
|
|
77
|
+
"txt",
|
|
78
|
+
"unknown",
|
|
79
|
+
"xlsx",
|
|
80
|
+
"xml",
|
|
81
|
+
"yaml",
|
|
82
|
+
"yml",
|
|
83
|
+
}
|
|
84
|
+
)
|
|
85
|
+
|
|
86
|
+
|
|
87
|
+
def normalize_key(value: str) -> str:
|
|
88
|
+
return re.sub(r"[^a-z0-9+]", "", value.lower())
|
|
89
|
+
|
|
90
|
+
|
|
91
|
+
def resolve_template(name: str, available: set[str]) -> str | None:
|
|
92
|
+
lowered = name.lower().strip()
|
|
93
|
+
if lowered in available:
|
|
94
|
+
return lowered
|
|
95
|
+
|
|
96
|
+
alias = LANGUAGE_ALIASES.get(lowered)
|
|
97
|
+
if alias and alias in available:
|
|
98
|
+
return alias
|
|
99
|
+
|
|
100
|
+
normalized = normalize_key(lowered)
|
|
101
|
+
for candidate in available:
|
|
102
|
+
if normalize_key(candidate) == normalized:
|
|
103
|
+
return candidate
|
|
104
|
+
|
|
105
|
+
alias = LANGUAGE_ALIASES.get(normalized)
|
|
106
|
+
if alias and alias in available:
|
|
107
|
+
return alias
|
|
108
|
+
|
|
109
|
+
return None
|
|
@@ -0,0 +1,163 @@
|
|
|
1
|
+
from __future__ import annotations
|
|
2
|
+
|
|
3
|
+
import json
|
|
4
|
+
import re
|
|
5
|
+
from functools import lru_cache
|
|
6
|
+
from importlib.resources import files
|
|
7
|
+
|
|
8
|
+
API_BASE = "https://www.toptal.com/developers/gitignore/api"
|
|
9
|
+
CANONICAL_URL = "https://www.toptal.com/developers/gitignore"
|
|
10
|
+
|
|
11
|
+
CREATED_LINE = re.compile(
|
|
12
|
+
r"^# Created by https://www\.toptal\.com/developers/gitignore/api/([^\s]+)\s*$",
|
|
13
|
+
re.MULTILINE,
|
|
14
|
+
)
|
|
15
|
+
EDIT_LINE = re.compile(
|
|
16
|
+
r"^# Edit at https://www\.toptal\.com/developers/gitignore\?templates=([^\s]+)\s*$",
|
|
17
|
+
re.MULTILINE,
|
|
18
|
+
)
|
|
19
|
+
SECTION_HEADER = re.compile(r"^### (.+?) ###\s*$", re.MULTILINE)
|
|
20
|
+
END_LINE = re.compile(
|
|
21
|
+
r"^# End of https://www\.toptal\.com/developers/gitignore/api/[^\s]+\s*$",
|
|
22
|
+
re.MULTILINE,
|
|
23
|
+
)
|
|
24
|
+
|
|
25
|
+
_DATA_ROOT = files("gitignore_cli") / "data"
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
class TemplateStore:
|
|
29
|
+
def __init__(self) -> None:
|
|
30
|
+
self._available: set[str] | None = None
|
|
31
|
+
self._order: dict[str, int] | None = None
|
|
32
|
+
self._section_titles: dict[str, str] = {}
|
|
33
|
+
self._template_cache: dict[str, str] = {}
|
|
34
|
+
|
|
35
|
+
@property
|
|
36
|
+
def available(self) -> set[str]:
|
|
37
|
+
if self._available is None:
|
|
38
|
+
self.refresh()
|
|
39
|
+
assert self._available is not None
|
|
40
|
+
return self._available
|
|
41
|
+
|
|
42
|
+
@property
|
|
43
|
+
def order(self) -> dict[str, int]:
|
|
44
|
+
if self._order is None:
|
|
45
|
+
self.refresh()
|
|
46
|
+
assert self._order is not None
|
|
47
|
+
return self._order
|
|
48
|
+
|
|
49
|
+
def refresh(self) -> None:
|
|
50
|
+
list_text = (_DATA_ROOT / "list.txt").read_text(encoding="utf-8")
|
|
51
|
+
self._available = {
|
|
52
|
+
line.strip().lower()
|
|
53
|
+
for line in list_text.splitlines()
|
|
54
|
+
if line.strip()
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
order_text = (_DATA_ROOT / "order.json").read_text(encoding="utf-8")
|
|
58
|
+
self._order = {key.lower(): value for key, value in json.loads(order_text).items()}
|
|
59
|
+
|
|
60
|
+
def _load_template(self, template: str) -> str:
|
|
61
|
+
template = template.lower()
|
|
62
|
+
if template not in self._template_cache:
|
|
63
|
+
path = _DATA_ROOT / "templates" / f"{template}.gitignore"
|
|
64
|
+
self._template_cache[template] = path.read_text(encoding="utf-8")
|
|
65
|
+
return self._template_cache[template]
|
|
66
|
+
|
|
67
|
+
def _strip_template_wrapper(self, content: str) -> str:
|
|
68
|
+
body = content
|
|
69
|
+
if CREATED_LINE.search(body):
|
|
70
|
+
body = CREATED_LINE.split(body, maxsplit=1)[-1]
|
|
71
|
+
body = EDIT_LINE.sub("", body, count=1)
|
|
72
|
+
if END_LINE.search(body):
|
|
73
|
+
body = END_LINE.split(body)[0]
|
|
74
|
+
return body.strip()
|
|
75
|
+
|
|
76
|
+
def fetch_templates(self, templates: list[str]) -> str:
|
|
77
|
+
if not templates:
|
|
78
|
+
return ""
|
|
79
|
+
ordered = self.sort_templates(list(set(templates)))
|
|
80
|
+
if len(ordered) == 1:
|
|
81
|
+
return self._load_template(ordered[0])
|
|
82
|
+
|
|
83
|
+
parts: list[str] = []
|
|
84
|
+
for template in ordered:
|
|
85
|
+
content = self._load_template(template)
|
|
86
|
+
sections = self.extract_sections(content)
|
|
87
|
+
if sections:
|
|
88
|
+
parts.append(sections[0][1].strip())
|
|
89
|
+
else:
|
|
90
|
+
parts.append(self._strip_template_wrapper(content))
|
|
91
|
+
return "\n\n".join(part for part in parts if part)
|
|
92
|
+
|
|
93
|
+
def section_title(self, template: str) -> str:
|
|
94
|
+
template = template.lower()
|
|
95
|
+
if template not in self._section_titles:
|
|
96
|
+
content = self.fetch_templates([template])
|
|
97
|
+
match = SECTION_HEADER.search(content)
|
|
98
|
+
self._section_titles[template] = match.group(1) if match else template
|
|
99
|
+
return self._section_titles[template]
|
|
100
|
+
|
|
101
|
+
def sort_templates(self, templates: list[str]) -> list[str]:
|
|
102
|
+
return sorted(set(templates), key=lambda name: (self.order.get(name, 9999), name))
|
|
103
|
+
|
|
104
|
+
def build_document(self, templates: list[str]) -> str:
|
|
105
|
+
ordered = self.sort_templates(templates)
|
|
106
|
+
if not ordered:
|
|
107
|
+
return ""
|
|
108
|
+
joined = ",".join(ordered)
|
|
109
|
+
body = self.fetch_templates(ordered)
|
|
110
|
+
if CREATED_LINE.search(body):
|
|
111
|
+
return body
|
|
112
|
+
|
|
113
|
+
sections = self.extract_sections(body)
|
|
114
|
+
content = "\n\n".join(section.strip() for _, section in sections if section.strip())
|
|
115
|
+
if not content:
|
|
116
|
+
content = body.strip()
|
|
117
|
+
return (
|
|
118
|
+
f"# Created by {API_BASE}/{joined}\n"
|
|
119
|
+
f"# Edit at {CANONICAL_URL}?templates={joined}\n\n"
|
|
120
|
+
f"{content.rstrip()}\n\n"
|
|
121
|
+
f"# End of {API_BASE}/{joined}\n"
|
|
122
|
+
)
|
|
123
|
+
|
|
124
|
+
def extract_sections(self, content: str) -> list[tuple[str, str]]:
|
|
125
|
+
sections: list[tuple[str, str]] = []
|
|
126
|
+
matches = list(SECTION_HEADER.finditer(content))
|
|
127
|
+
for index, match in enumerate(matches):
|
|
128
|
+
title = match.group(1)
|
|
129
|
+
start = match.start()
|
|
130
|
+
end = matches[index + 1].start() if index + 1 < len(matches) else len(content)
|
|
131
|
+
section_text = content[start:end].strip()
|
|
132
|
+
if END_LINE.search(section_text):
|
|
133
|
+
section_text = END_LINE.split(section_text)[0].strip()
|
|
134
|
+
sections.append((title, section_text))
|
|
135
|
+
return sections
|
|
136
|
+
|
|
137
|
+
def section_for_template(self, template: str) -> str:
|
|
138
|
+
content = self.fetch_templates([template])
|
|
139
|
+
sections = self.extract_sections(content)
|
|
140
|
+
if sections:
|
|
141
|
+
return sections[0][1]
|
|
142
|
+
return content.strip()
|
|
143
|
+
|
|
144
|
+
def title_to_template(self, title: str, candidates: list[str] | None = None) -> str | None:
|
|
145
|
+
normalized_title = re.sub(r"[^a-z0-9+]", "", title.lower())
|
|
146
|
+
search_set = [candidate.lower() for candidate in (candidates or [])]
|
|
147
|
+
|
|
148
|
+
for template in search_set:
|
|
149
|
+
if template not in self.available:
|
|
150
|
+
continue
|
|
151
|
+
if re.sub(r"[^a-z0-9+]", "", template) == normalized_title:
|
|
152
|
+
return template
|
|
153
|
+
section_title = re.sub(r"[^a-z0-9+]", "", self.section_title(template).lower())
|
|
154
|
+
if section_title == normalized_title:
|
|
155
|
+
return template
|
|
156
|
+
return None
|
|
157
|
+
|
|
158
|
+
|
|
159
|
+
@lru_cache(maxsize=1)
|
|
160
|
+
def get_store() -> TemplateStore:
|
|
161
|
+
store = TemplateStore()
|
|
162
|
+
store.refresh()
|
|
163
|
+
return store
|