decorator ---- python decorator 装饰器

类装饰器,修饰类的装饰器 class decorator

  • 参考:

  • 例子

     1
     2
     3
     4
     5
     6
     7
     8
     9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    
    from functools import wraps
    
    def debug(func):
        """decorator for debugging passed function
        """
            @wraps(func)
        def wrapper(*args, **kwargs):
            print("Full name of this method:", func.__qualname__)
            return func(*args, **kwargs)
        return wrapper
    
    
    # 类装饰器
    def debugmethods(cls):
        '''class decorator make use of debug decorator
        to debug class methods '''
    
        # check in class dictionary for any callable(method)
        # if exist, replace it with debugged version
        for key, val in vars(cls).items():
            if callable(val):
                setattr(cls, key, debug(val))
        return cls
    
    # sample class
    @debugmethods
    class Calc:
        def add(self, x, y):
            return x+y
        def mul(self, x, y):
            return x*y
        def div(self, x, y):
            return x/y
    
    mycal = Calc()
    print(mycal.add(2, 3))
    print(mycal.mul(5, 2))

pdf parsing ---- pdf 文本解析

参考

工具列表:

中文 PDF 抽取工具

pdf 转图片

image rendering ---- render image with python 图片处理

图片存储网站

工具

Spacemacs Notes

切换国内源

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
    (defun dotspacemacs/user-init ()
      "Initialization function for user code.
    It is called immediately after `dotspacemacs/init', before layer configuration
    executes.
     This function is mostly useful for variables that need to be set
    before packages are loaded. If you are unsure, you should try in setting them in
    `dotspacemacs/user-config' first."
      (setq configuration-layer-elpa-archives
      '(("melpa-cn" . "http://elpa.emacs-china.org/melpa/")
        ("org-cn"   . "http://elpa.emacs-china.org/org/")
        ("gnu-cn"   . "http://elpa.emacs-china.org/gnu/")))
      )



  (setq configuration-layer-elpa-archives
        '(
          ("melpa-stable-cn" . "http://mirrors.tuna.tsinghua.edu.cn/elpa/melpa-stable")
          ("melpa-cn" . "http://mirrors.tuna.tsinghua.edu.cn/elpa/melpa/")
          ("org-cn"   . "http://mirrors.tuna.tsinghua.edu.cn/elpa/org/")
          ("gnu-cn"   . "http://mirrors.tuna.tsinghua.edu.cn/elpa/gnu/")))

自定义 layer 教程

  • 参考