Skip to content

Instantly share code, notes, and snippets.

View yuyosy's full-sized avatar
💭
I may be slow to respond.

yuyosy yuyosy

💭
I may be slow to respond.
View GitHub Profile
import argparse
import sys
from pathlib import Path
import yaml
from lxml import etree
def resource_path(*args:str) -> Path:
base_path = ''
from lxml import etree
parser = etree.XMLParser( remove_blank_text=True)
tree = etree.parse('data/xml/data.xml', parser)
for addr in tree.xpath('//PurchaseOrder'):
ver_el = etree.Element('version')
ver_el.text = 'xxxx'
addr.insert(0, ver_el)
# generated by Git for Windows
test -f ~/.profile && . ~/.profile
test -f ~/.bashrc && . ~/.bashrc
env=~/.ssh/agent.env
agent_load_env() {
test -f "$env" && . "$env" >| /dev/null
}
RED="\[\033[0;31m\]"
GREEN="\[\033[0;32m\]"
YELLOW="\[\033[0;33m\]"
BLUE="\[\033[0;34m\]"
PURPLE="\[\033[0;35m\]"
CYAN="\[\033[0;36m\]"
LIGHT_GRAY="\[\033[1;30m\]"
LIGHT_RED="\[\033[1;31m\]"
LIGHT_GREEN="\[\033[1;32m\]"
# https://github.com/Tinche/cattrs
# https://pypi.org/project/cattrs/
import json
from dataclasses import dataclass
from typing import Dict, Optional, Union
from cattr import register_structure_hook, structure
import os
import re
def rename_action(args: any):
print('--------------------')
print(os.path.abspath(args.root) + ' :')
print('--------------------')
pathlist = []
listup(args, pathlist)
import wx
import ctypes
import logging
import wx
class FileDropToObject(wx.FileDropTarget):
def __init__(self, target):
wx.FileDropTarget.__init__(self)
self.target = target
import re
from functools import reduce
def set_attr(obj, keystr, value, delimiter='.'):
key_list = keystr.split(delimiter)
o, k = _set_parse_keystr(obj, key_list)
o[k] = value
print(' -+', o[k])
return obj
import base64
import os
import sys
def basestr_to_file(s, outfile_path):
with open(outfile_path, "wb") as f:
f.write(base64.b85decode(s))
if __name__ == "__main__":
args = sys.argv
import base64
import os
import sys
def file_to_basestr(file_path):
with open(file_path, "rb") as f:
return base64.b85encode(f.read())
if __name__ == "__main__":
args = sys.argv