Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add doom-snippets for python-base-mode #49

Merged
merged 1 commit into from
Feb 16, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
88 changes: 86 additions & 2 deletions templates/python-base.eld
Original file line number Diff line number Diff line change
@@ -1,6 +1,90 @@
python-base-mode

(__contains__ "def __contains__(self, el):" n> p n> "pass")
(__enter__ "def __enter__(self):" n> p n> "return self")
(__eq__ "def __eq__(self, other):" n> "return self." p " == other." q)
(__exit__ "def __exit__(self, type, value, traceback):" n> p n> "pass")
(__getitem__ "def __len__(self):" n> p n> "pass")
(__iter__ "def __iter__(self):" n> "return " q)
(__new__ "def __new__(mcs, name, bases, dict):" n> p n> "return type.__new__(mcs, name, bases, dict)")
(__setitem__ "__all__ = [" n> p n> "]")
(arg "parser.add_argument('-" p "', '--" p "'," n> p ")")
(arg_positional "parser.add_argument('" p "', " p ")")
(assert "assert " q)
(assertEqual "self.assertEqual(" p ", " p ")")
(assertFalse "self.assertFalse(" p ")")
(assertIn "self.assertIn(" p ", " p ")")
(assertNotEqual "self.assertNotEqual(" p ", " p ")")
(assertRaises "assertRaises(" p ", " p ")")
(assertRaises-with "with self.assertRaises(" p "):" n> q)
(assertTrue "self.assertTrue(" p ")")
(celery_pdb "from celery.contrib import rdb; rdb.set_trace()")
(class "class " p "(" p "):" n> q)
(classmethod "@classmethod" n> "def " p "(cls, " p "):" n> q)
(def_decorator "def " p "(func):" n> p n> "def _" p "(*args, **kwargs):" n> p n> "ret = func(*args, **kwargs)" n> p n> "return ret" n n> "return _" q)
(def_function "def " p "(" p "):" n> q)
(doc "\"\"\"" p "\"\"\"")
(doctest ">>> " p n> q)
(for "for " p " in " p ":" n> q)
(tr & "import " p "; " p ".set_trace()" q)
(from "from " p " import " q)
(function_docstring "def " p "(" p "):" n> "\"\"\"" p "\"\"\"" n> q)
(if "if " p ":" n> q)
(ife "if " p ":" n> p n> "else:" n> q)
(ifmain "if __name__ == '__main__':" n> q)
(ig "# type: ignore" q)

(import "import " p q)
(init "def __init__(self" p "):" n> q)
(init_docstring "def __init__(self" p "):" n> "\"\"\"" p "\"\"\"" n> q)
(interact "import code; code.interact(local=locals())")
(ipdb_trace "import ipdb; ipdb.set_trace()")
(lambda "lambda " p ": " q)
(list "[" p " for " p " in " p "]")
(logger_name "logger = logging.getLogger(__name__)")
(logging "logger = logging.getLogger(\"" p "\")" n> "logger.setLevel(logging." p ")")
(main "def main():" n> q)
(metaclass "__metaclass__ = type")
(method "def " p "(self" p "):" n> q)
(method_docstring "def " p "(self" p "):" n> "\"\"\"" p "\"\"\"" n> q)
(not_impl "raise NotImplementedError")
(np "import numpy as np" n> q)
(parse_args "def parse_arguments():" n> "parser = argparse.ArgumentParser(description='" p "')" n> p n> "return parser.parse_args()")
(pd "import pandas as pd" n> q)
(tf "import tensorflow as tf" n> q)
(tr & "import " p "; " p ".set_trace()" q)
(parser "parser = argparse.ArgumentParser(description='" p "')" n> q)
(pass "pass")
(print "print(" p ")")
(prop "def " p "():"
n> "doc = \"\"\"" p "\"\"\""
n> "def fget(self):"
n> "return self._" p
n> n> "def fset(self, value):"
n> "self._" p " = value"
n> n> "def fdel(self):"
n> "del self._" p
n> "return locals()"
n> p " = property(**" p "())")
(reg p " = re.compile(r\"" p "\")")
(__repr__ "def __repr__(self):" n> q)
(return "return " q)
(script "#!/usr/bin/env python" n n> "def main():" n> "pass" n n> "if __name__ == '__main__':" n> "main()")
(self "self." q)
(self_without_dot "self")
(selfassign "self." p " = " q)
(setdef p ".setdefault(" p ", []).append(" p ")")
(setup "from setuptools import setup" n n> "package = '" p "'" n> "version = '" p "'" n n> "setup(name=package," n> "version=version," n> "description=\"" p "\"," n> "url='" p "'" p ")")
(shebang_line "#!/usr/bin/env python" n> q)
(size "sys.getsizeof(" p ")")
(static "@staticmethod" n> "def " p "(" p "):" n> q)
(__str__ "def __str__(self):" n> q)
(super "super(" p ", self)." p "(" p ")")
(test_class "class Test" p "(" p "):" n> q)
(test_file "import unittest" n> "from " p " import *" n> p n> "if __name__ == '__main__':" n> "unittest.main()")
(trace "import pdb; pdb.set_trace()")
(try "try:" n> p n> "except " p ":" n> q)
(tryelse "try:" n> p n> "except " p ":" n> p n> "else:" n> q)
(__unicode__ "def __unicode__(self):" n> q)
(utf-8_encoding "# -*- coding: utf-8 -*-")
(while "while " p ":" n> q)
(with "with " p p ":" n> q)
(with_statement "from __future__ import with_statement"))
Loading