Skip to content

Commit

Permalink
Fix: vdffz.py missing, dropping vdffz does nothing
Browse files Browse the repository at this point in the history
  • Loading branch information
kozec committed Aug 21, 2016
1 parent 6280c4f commit db309a8
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 7 deletions.
21 changes: 21 additions & 0 deletions scc/foreign/vdffz.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
#!/usr/bin/env python2
"""
Imports VDFFZ profile and converts it to Profile object.
VDFFZ is just VDF encapsulated in json, so this just gets one value and calls
VDFProfile to decode rest.
"""
from vdf import VDFProfile
from scc.lib.vdf import parse_vdf

import json, logging
log = logging.getLogger("import.vdffz")

class VDFFZProfile(VDFProfile):
def load(self, filename):
try:
data = json.loads(open(filename, "r").read())
except Exception, e:
raise ValueError("Failed to parse JSON")
if 'ConfigData' not in data:
raise ValueError("ConfigData missing in JSON")
self.load_data(parse_vdf(data['ConfigData'].encode('utf-8')))
16 changes: 9 additions & 7 deletions scc/gui/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -806,13 +806,15 @@ def on_drag_data_received(self, widget, context, x, y, data, info, time):
if len(data.get_uris()):
uri = data.get_uris()[0]
giofile = Gio.File.new_for_uri(uri)
if giofile.get_path() and giofile.get_path().endswith(".vdf"):
# Local file, looks like vdf profile
from scc.gui.import_dialog import ImportDialog
gs = ImportDialog(self)
gs.show(self.window)
# Skip first screen and try to import this file
gs.on_preload_finished(gs.set_file, giofile.get_path())
if giofile.get_path():
path = giofile.get_path()
if path.endswith(".vdf") or path.endswith(".vdffz"):
# Local file, looks like vdf profile
from scc.gui.import_dialog import ImportDialog
gs = ImportDialog(self)
gs.show(self.window)
# Skip first screen and try to import this file
gs.on_preload_finished(gs.set_file, giofile.get_path())


class UndoRedo(object):
Expand Down

0 comments on commit db309a8

Please sign in to comment.