1
0
mirror of https://github.com/Foltik/dotfiles synced 2025-01-20 22:06:55 -05:00

Switch to yaml for package definitions

This commit is contained in:
Jack Foltz 2018-12-01 14:24:43 -05:00
parent 56bfd29136
commit e24a1d1f55
Signed by: foltik
GPG Key ID: D1F0331758D1F29A
9 changed files with 101 additions and 99 deletions

View File

@ -1 +1,31 @@
from subprocess import call
#!/bin/python
import curses
from lib.parse import Category, Package, parse
from lib.menu import Menu
from lib.configure import configure
categories = parse('packages.yml')
def noop():
pass
class App:
def __init__(self, stdscreen):
self.screen = stdscreen
curses.curs_set(0)
submenu_items = [
('do stuff', noop)
]
submenu = Menu(self.screen, submenu_items)
main_menu_items = [
('install', noop),
('submenu', submenu.display)
]
main_menu = Menu(self.screen, main_menu_items)
main_menu.display()
if __name__ == '__main__':
curses.wrapper(App)

0
lib/__init__.py Normal file
View File

5
lib/configure.py Normal file
View File

@ -0,0 +1,5 @@
from subprocess import call
from lib.parse import Package
def configure(package):
pass

View File

@ -1,5 +1,3 @@
#!/usr/bin/python
import curses
from curses import panel
@ -76,27 +74,3 @@ class Menu(BaseMenu):
self.should_exit = False
self.down()
class App(object):
def __init__(self, stdscreen):
self.screen = stdscreen
curses.curs_set(0)
submenu_items = [
('beep', curses.beep),
('flash', curses.flash)
]
submenu = Menu(self.screen, submenu_items)
main_menu_items = [
('beep', curses.beep),
('flash', curses.flash),
('submenu', submenu.display)
]
main_menu = Menu(self.screen, main_menu_items)
main_menu.display()
if __name__ == '__main__':
curses.wrapper(App)

26
lib/parse.py Executable file
View File

@ -0,0 +1,26 @@
import yaml
class Package:
def __init__(self, obj):
if isinstance(obj, dict):
self.name, props = next(iter(obj.items()))
self.source = 'core'
for key, value in props.items():
setattr(self, key, value)
else:
self.name = obj
self.source = 'core'
def __repr__(self):
return self.name
class Category:
def __init__(self, name, packages):
self.name = name
self.packages = [Package(pkg) for pkg in packages]
def __repr__(self):
return self.name + ': ' + str(self.packages)
def parse(file):
f = open(file, 'r')
data = yaml.load(f)
return [Category(name, packages) for name, packages in data.items()]

View File

@ -1,28 +0,0 @@
* Fonts
core ttf-dejavu
core otf-fira-code
core adobe-source-han-sans-jp-fonts
git https://github.com/domtronn/all-the-icons.el all-the-icons.fish
* System Tools
core networkmanager
* Window Manager
* Desktop Tools
core rofi
* Editors
core emacs
core neovim
* Music
core mpd
core mpc
core ncmpcpp
core beets
* Terminal
core alacritty
core alacritty-terminfo
core fish

39
packages.yml Normal file
View File

@ -0,0 +1,39 @@
Base:
- fish
- systemd:
source: none
Terminal:
- alacritty
- alacritty-terminfo
Editors:
- emacs:
config: .emacs.d
user-units:
- emacs.service
- neovim
System Tools:
- networkmanager
Window Manager:
- ppi3-git:
source: aur
Desktop Tools:
- python-pywal:
script: wal.fish
config: .config/wal
user-units:
- wallpaper.service
- wallpaper.timer
- rofi
Fonts:
- ttf-dejavu
- otf-fira-code
- adobe-source-han-sans-jp-fonts
- all-the-icons:
source: git
url: https://github.com/domtronn/all-the-icons.el

View File

@ -1,34 +0,0 @@
#!/usr/bin/python
import re
class Package:
def __init__(self, line):
self.type = line[0]
self.name = line[1]
self.script = line[2] if len(line) == 3 else None
@staticmethod
def is_package_line(line):
return re.match(r"^[^*]+", line[0])
class Category:
def __init__(self, line):
self.name = ' '.join(line[1:])
self.packages = []
@staticmethod
def is_category_line(line):
return re.match(r"^\*+", line[0])
def split(lines):
return list(map(lambda line: line.rstrip().split(' '), lines))
def parse_package_listing(file):
f = open(file, 'r')
categories = []
category = None
for line in split(f.readlines()):
if Category.is_category_line(line):
category = Category(line)
categories.append(category)
elif Package.is_package_line(line):
category.packages.append(Package(line))
return categories

View File

@ -1,10 +0,0 @@
#!/usr/bin/python
import parse
categories = parse.parse_package_listing('packages.org')
for category in categories:
print(category.name)
for package in category.packages:
print('- ' + package.name)