# Path: modules/mylib_get_data.py
# def games_info(data_dir):
# def get_info(games_list, mylib_dir):
# 
# Path: modules/goglib_get_data.py
# def games_info(data_dir):
# 
# Path: modules/get_banner.py
# def get_banner(game_name, url, banner_path, lib):
# 
#     banner_req = urllib_request(url)
# 
#     try:
# 
#         if not os.path.exists(banner_path):
#             os.makedirs(banner_path)
# 
#         banner_data = urllib_urlopen(banner_req).read()
#         banner_file = open(banner_path + '/' + game_name + '.jpg', 'wb')
#         banner_file.write(banner_data)
#         banner_file.close()
# 
#         pic_src = Image.open(banner_path + '/' + game_name + '.jpg')
#         pic = pic_src.resize((518, 240), PIL.Image.ANTIALIAS)
#         pic.save(banner_path + '/' + game_name + '.jpg')
# 
#         if lib == 'goglib':
# 
#             if not os.path.exists(banner_path + '/unavailable/'):
#                 os.makedirs(banner_path + '/unavailable/')
# 
#             new_pic = Image.open(banner_path + '/' + game_name + '.jpg')
#             pic_grey = new_pic.convert('L')
#             pic_grey.save(banner_path + '/unavailable/' + game_name + '.jpg')
# 
#     except urllib_urlerror as e:
#         print(e.reason)
#     except urllib_httperror as e:
#         print(e.code)
#         print(e.read())


import os, sys, subprocess, shutil
import gi
import gettext
    import sys
from gi.repository import Gtk, Gdk
    from urllib2 import Request as urllib_request
    from urllib2 import urlopen as urllib_urlopen
    from urllib2 import URLError as urllib_urlerror
    from urllib2 import HTTPError as urllib_httperror
    from urllib.request import Request as urllib_request
    from urllib.request import urlopen as urllib_urlopen
    from urllib.request import URLError as urllib_urlerror
    from urllib.request import HTTPError as urllib_httperror
    from ConfigParser import ConfigParser as ConfigParser
    from configparser import ConfigParser as ConfigParser
from modules import mylib_get_data, goglib_get_data, get_banner
        if self.lib == 'mylib':
            new_scripts_dir = tmp + '/games_nebula_' + self.lib + '_scripts-master/free/'
        else:
            new_scripts_dir = tmp + '/games_nebula_' + self.lib + '_scripts-master/'

        subprocess.call(['7z', 'x', '-aoa', '-o' + tmp, archive_path])
        os.remove(new_scripts_dir + 'LICENSE')

        git_sctipts = os.listdir(new_scripts_dir)
        existing_scripts_0 = os.listdir(scripts_dir_0)
        existing_scripts_1 = os.listdir(scripts_dir_1)
        existing_scripts = existing_scripts_0 + existing_scripts_1

        new_scripts = []
        for script in git_sctipts:
            if script not in existing_scripts:
                new_scripts.append(script)
                os.rename(new_scripts_dir + script, scripts_dir_0)

        if self.overwrite == True:
            os.system('cp -r "' + new_scripts_dir + '"* "' + scripts_dir_0 + '"')

        shutil.rmtree(new_scripts_dir)
        os.remove(archive_path)

        new_scripts = sorted(new_scripts)
        n_new_scripts = len(new_scripts)

        if self.lib == 'goglib':


# Path: modules/mylib_get_data.py
# def games_info(data_dir):
# def get_info(games_list, mylib_dir):
# 
# Path: modules/goglib_get_data.py
# def games_info(data_dir):
# 
# Path: modules/get_banner.py
# def get_banner(game_name, url, banner_path, lib):
# 
#     banner_req = urllib_request(url)
# 
#     try:
# 
#         if not os.path.exists(banner_path):
#             os.makedirs(banner_path)
# 
#         banner_data = urllib_urlopen(banner_req).read()
#         banner_file = open(banner_path + '/' + game_name + '.jpg', 'wb')
#         banner_file.write(banner_data)
#         banner_file.close()
# 
#         pic_src = Image.open(banner_path + '/' + game_name + '.jpg')
#         pic = pic_src.resize((518, 240), PIL.Image.ANTIALIAS)
#         pic.save(banner_path + '/' + game_name + '.jpg')
# 
#         if lib == 'goglib':
# 
#             if not os.path.exists(banner_path + '/unavailable/'):
#                 os.makedirs(banner_path + '/unavailable/')
# 
#             new_pic = Image.open(banner_path + '/' + game_name + '.jpg')
#             pic_grey = new_pic.convert('L')
#             pic_grey.save(banner_path + '/unavailable/' + game_name + '.jpg')
# 
#     except urllib_urlerror as e:
#         print(e.reason)
#     except urllib_httperror as e:
#         print(e.code)
#         print(e.read())


# Path: get_scripts.py
import os, sys, subprocess, shutil
import gi
import gettext
    import sys
from gi.repository import Gtk, Gdk
    from urllib2 import Request as urllib_request
    from urllib2 import urlopen as urllib_urlopen
    from urllib2 import URLError as urllib_urlerror
    from urllib2 import HTTPError as urllib_httperror
    from urllib.request import Request as urllib_request
    from urllib.request import urlopen as urllib_urlopen
    from urllib.request import URLError as urllib_urlerror
    from urllib.request import HTTPError as urllib_httperror
    from ConfigParser import ConfigParser as ConfigParser
    from configparser import ConfigParser as ConfigParser
from modules import mylib_get_data, goglib_get_data, get_banner

        if self.lib == 'mylib':
            new_scripts_dir = tmp + '/games_nebula_' + self.lib + '_scripts-master/free/'
        else:
            new_scripts_dir = tmp + '/games_nebula_' + self.lib + '_scripts-master/'

        subprocess.call(['7z', 'x', '-aoa', '-o' + tmp, archive_path])
        os.remove(new_scripts_dir + 'LICENSE')

        git_sctipts = os.listdir(new_scripts_dir)
        existing_scripts_0 = os.listdir(scripts_dir_0)
        existing_scripts_1 = os.listdir(scripts_dir_1)
        existing_scripts = existing_scripts_0 + existing_scripts_1

        new_scripts = []
        for script in git_sctipts:
            if script not in existing_scripts:
                new_scripts.append(script)
                os.rename(new_scripts_dir + script, scripts_dir_0)

        if self.overwrite == True:
            os.system('cp -r "' + new_scripts_dir + '"* "' + scripts_dir_0 + '"')

        shutil.rmtree(new_scripts_dir)
        os.remove(archive_path)

        new_scripts = sorted(new_scripts)
        n_new_scripts = len(new_scripts)

        if self.lib == 'goglib':


            goglib_data = goglib_get_data.games_info(data_dir)