Commit 5ae8f22c authored by Shashank Kumar's avatar Shashank Kumar

conflict resolved

parents 48aca0a0 bbcb9797
......@@ -8,7 +8,6 @@ before_script:
- apt-get install -y ffmpeg git
- pip3 install pipenv
- pipenv install --skip-lock
- pipenv install --skip-lock git+http://github.com/kivy/kivy.git#egg=kivy-1.10.1
pylint:
type: test
......@@ -21,5 +20,6 @@ pylint:
pytest:
type: test
script:
- apt-get install -y gnupg2
- pipenv install --skip-lock pytest pytest-cov
- pipenv run pytest tests --cov=modules
......@@ -11,6 +11,7 @@ ipdb = "==0.11"
[packages]
cython = "==0.28"
kivy = "==1.10.1"
python-gnupg = "==0.4.3"
requests = "==2.19.1"
......
{
"_meta": {
"hash": {
"sha256": "7e795eb3ea979205c92d0da17b18b772855d81c1f510165db414636c3e46eb46"
"sha256": "9c2f51827b73133cef042216d7ac81263a29b082dd28e6799c096cbaa9417ef4"
},
"pipfile-spec": 6,
"requires": {
......@@ -66,6 +66,14 @@
"index": "pypi",
"version": "==0.28"
},
"docutils": {
"hashes": [
"sha256:02aec4bd92ab067f6ff27a38a38a41173bf01bed8f89157768c1573f53e474a6",
"sha256:51e64ef2ebfb29cae1faa133b3710143496eca21c530f3f71424d77687764274",
"sha256:7a4bd47eaf6596e1295ecb11361139febe29b084a87bf005bf899f9a42edc3c6"
],
"version": "==0.14"
},
"idna": {
"hashes": [
"sha256:156a6814fb5ac1fc6850fb002e0852d56c0c8d2531923a51032d1b70760e186e",
......@@ -73,6 +81,39 @@
],
"version": "==2.7"
},
"kivy": {
"hashes": [
"sha256:05985f3e16065a476293695cef39f0b8faa81353475692b8c60ca2530ba08175",
"sha256:44a64f72182dd40aceef2041259359513dafeeecc0891d2d23056799d51babb0",
"sha256:48a0d3edf8fbc9206ebb7abae8d7e2017c5d5f81cf6e76c2e5510193d607420e",
"sha256:6bbeccc9c52a264fb53b7aaa344d865f054da09cc08e15b482754c2d4e3a5cfd",
"sha256:7131a24e30b80f9b7b6e7a1c124f0b5002ef58de35856aff38762b216a4e77fb",
"sha256:77cd45a1aee9061c7474020def1b7b31eb4665e5424c45c23a6a7e4f5afee6b9",
"sha256:7ce9e88b75de47a3f1d52cbe6924c18cafc83fa102e54f6794d241746e93fdff",
"sha256:8f912c0742c7f9582676106ae5a526c3f38bc01a196edd26186c74975b08fad0",
"sha256:952d7483b4f29ebeabb612897cdfdcdd12c33f1bdb51fb0082d36dfcf543ec0b",
"sha256:b0ec00fd3a6dbe56c31510151e8bb14f54390dbc31c5047d61aa90d069c5ec04",
"sha256:c4ad43fb04c899be27baa5a6e382c79620fc3602213221cb97da2280f345b2d6",
"sha256:cb6f052d69748a7db70970e5a8ee3d96506751fcfcc8bf979424fcd788473037",
"sha256:d1113ee88eaff5127ecc05121570f1f2adec21d7f1699ef1c6c2bf4396e51578"
],
"index": "pypi",
"version": "==1.10.1"
},
"kivy-garden": {
"hashes": [
"sha256:9b7d9de5efacbcd0c4b3dd873b30622a86093c9965aa47b523c7a32f3eb34610",
"sha256:c256f42788421273a08fbb0a228f0fb0e80dd86b629fb8c0920507f645be6c72"
],
"version": "==0.1.4"
},
"pygments": {
"hashes": [
"sha256:78f3f434bcc5d6ee09020f92ba487f95ba50f1e3ef83ae96b9d5ffa1bab25c5d",
"sha256:dbae1046def0efb574852fab9e90209b23f556367b5a320c0bcb871c77c3e8cc"
],
"version": "==2.2.0"
},
"python-gnupg": {
"hashes": [
"sha256:2d158dfc6b54927752b945ebe57e6a0c45da27747fa3b9ae66eccc0d2147ac0d",
......@@ -131,10 +172,13 @@
"sha256:03481e81d558d30d230bc12999e3edffe392d244349a90f4ef9b88425fac74ba",
"sha256:0b136648de27201056c1869a6c0d4e23f464750fd9a9ba9750b8336a244429ed",
"sha256:104ab3934abaf5be871a583541e8829d6c19ce7bde2923b2751e0d3ca44db60a",
"sha256:10a46017fef60e16694a30627319f38a2b9b52e90182dddb6e37dcdab0f4bf95",
"sha256:15b111b6a0f46ee1a485414a52a7ad1d703bdf984e9ed3c288a4414d3871dcbd",
"sha256:198626739a79b09fa0a2f06e083ffd12eb55449b5f8bfdbeed1df4910b2ca640",
"sha256:1c383d2ef13ade2acc636556fd544dba6e14fa30755f26812f54300e401f98f2",
"sha256:23d341cdd4a0371820eb2b0bd6b88f5003a7438bbedb33688cd33b8eae59affd",
"sha256:28b2191e7283f4f3568962e373b47ef7f0392993bb6660d079c62bd50fe9d162",
"sha256:2a5b73210bad5279ddb558d9a2bfedc7f4bf6ad7f3c988641d83c40293deaec1",
"sha256:2eb564bbf7816a9d68dd3369a510be3327f1c618d2357fa6b1216994c2e3d508",
"sha256:337ded681dd2ef9ca04ef5d93cfc87e52e09db2594c296b4a0a3662cb1b41249",
"sha256:3a2184c6d797a125dca8367878d3b9a178b6fdd05fdc2d35d758c3006a1cd694",
......@@ -261,10 +305,10 @@
},
"parso": {
"hashes": [
"sha256:8105449d86d858e53ce3e0044ede9dd3a395b1c9716c696af8aa3787158ab806",
"sha256:d250235e52e8f9fc5a80cc2a5f804c9fefd886b2e67a2b1099cf085f403f8e33"
"sha256:35704a43a3c113cce4de228ddb39aab374b8004f4f2407d070b6a2ca784ce8a2",
"sha256:895c63e93b94ac1e1690f5fdd40b65f07c8171e3e53cbd7793b5b96c0e0a7f24"
],
"version": "==0.3.0"
"version": "==0.3.1"
},
"pexpect": {
"hashes": [
......
......@@ -35,7 +35,8 @@ sudo apt-get install -y \
libswscale-dev \
libavformat-dev \
libavcodec-dev \
zlib1g-dev
zlib1g-dev \
gnupg2
# Install gstreamer for audio, video (optional)
sudo apt-get install -y \
......@@ -52,11 +53,7 @@ Step 4: Install application dependencies (this might take a while, grab a cup of
`$ pipenv install`
Step 5: Install Kivy
`$ pipenv install --skip-lock git+http://github.com/kivy/kivy.git#egg=kivy-1.10.1`
Step 6: Run New Contributor Wizard
Step 5: Run New Contributor Wizard
`$ pipenv run python main.py`
......
......@@ -35,10 +35,11 @@ class Encryption(BoxLayout):
self.ids[option_to_enable + '_box'].canvas.before.children[0].rgba = [1, 1, 1, 1]
self.ids[option_to_enable].color = (0, 0, 0, 1)
all_options_items_copy = self.all_options_items[:]
all_options_items_copy.remove(option_to_enable)
# removing enabled option from the list in order to disable all other options
options_to_disable = self.all_options_items[:]
options_to_disable.remove(option_to_enable)
for option in all_options_items_copy:
for option in options_to_disable:
self.ids[option + '_box'].canvas.before.children[0].rgba = [0, 0, 0, 1]
self.ids[option].color = (1, 1, 1, 1)
self.ids['encryption_content_box'].remove_widget(self.all_options[option])
......
......@@ -9,12 +9,9 @@ from kivy.lang import Builder
from kivy.clock import Clock
from modules.encryption.tools.all_tools.exceptions import GPGError
from modules.encryption.tools.all_tools.services import create_key_pair as ckp
from modules.encryption.tools.all_tools.services import create_gpg_key_pair
from modules.encryption.tools.all_tools.validations import (
validate_email,
validate_name,
validate_comment,
validate_expire_date
validate_email, validate_name, validate_comment, validate_expire_date
)
......@@ -104,7 +101,7 @@ class CreateKeyPair(BoxLayout):
return validation_successful
def create_key_pair(self):
def creating_key_pair(self):
'''
Processing user input to create key pair
'''
......@@ -114,7 +111,7 @@ class CreateKeyPair(BoxLayout):
'''
Add Key fingerprint to label and button
'''
creating_key_pair_popup.ids['create_key_pair_popup_label'].text = args[0]
creating_key_pair_popup.ids['create_gpg_key_pair_popup_label'].text = args[0]
if self.validate():
name = self.ids['input_name'].text
......@@ -124,7 +121,7 @@ class CreateKeyPair(BoxLayout):
try:
creating_key_pair_popup.open()
key_fingerprint = ckp(
key_fingerprint = create_gpg_key_pair(
name=name,
email=email,
comment=comment,
......
......@@ -7,9 +7,10 @@ from kivy.uix.label import Label
from kivy.uix.popup import Popup
from kivy.lang import Builder
from modules.encryption.tools.all_tools.services import list_all_keys, decrypt_message
from modules.encryption.tools.all_tools.utils import extract_key_uid_info
from modules.encryption.tools.all_tools.exceptions import GPGError
from modules.encryption.tools.all_tools.services import (
list_gpg_all_keys, decrypt_message, create_key_listing_widget
)
Builder.load_file('./ui/encryption/all_tools/decrypt_a_message.kv')
......@@ -46,6 +47,12 @@ class DecryptMessagePopup(Popup):
'''
class NoKeyPresentDecrypt(BoxLayout):
'''
NoKeyPresentDecrypt will be displayed in case if no key is present
'''
class DecryptAMessage(BoxLayout):
'''
DecryptAMessage integrated UI with helper functions
......@@ -53,7 +60,7 @@ class DecryptAMessage(BoxLayout):
def __init__(self, **kwargs):
super(DecryptAMessage, self).__init__(**kwargs)
all_keys = list_all_keys()
all_keys = list_gpg_all_keys()
self.populate_with_keys(all_keys['all_private_keys'])
def populate_with_keys(self, all_private_keys):
......@@ -61,28 +68,15 @@ class DecryptAMessage(BoxLayout):
populate_with_keys displays all the available private keys that can be
used to decrypt message
'''
for fingerprint, key_info in all_private_keys.items():
user_info = extract_key_uid_info(key_info['uids'][0])
key_column_box = KeyColumnBox()
key_box = DecryptKeyBox()
key_box.ids['Key_button'].id = fingerprint # pylint: disable=invalid-name
key_box.ids['Key_button'].bind(
on_press=self.decrypt_message_popup
)
key_column_box.add_widget(key_box)
key_info_label = KeyInfoLabel(
text='\n'.join(user_info.values())
)
key_column_box.add_widget(key_info_label)
fingerprint_text = fingerprint[:len(fingerprint) // 2] + '\n' +\
fingerprint[len(fingerprint) // 2:]
key_info_label = KeyInfoLabel(text=fingerprint_text)
key_column_box.add_widget(key_info_label)
self.ids['scroll_view_box'].add_widget(key_column_box)
if all_private_keys.items():
for key_column_box in create_key_listing_widget(
self.decrypt_message_popup, all_private_keys, DecryptKeyBox,
KeyColumnBox, KeyInfoLabel
):
self.ids['scroll_view_box'].add_widget(key_column_box)
else:
self.ids['scroll_view_box'].clear_widgets()
self.ids['scroll_view_box'].add_widget(NoKeyPresentDecrypt())
@staticmethod
def decrypt_message_popup(*args):
......@@ -94,8 +88,8 @@ class DecryptAMessage(BoxLayout):
def get_decrypted_message(*args):
'''
get_decrypted_message receives all the data from input box in order to
fetch decrypted message
get_decrypted_message receives all the data from input box in order
to fetch decrypted message
'''
if args:
encrypted_message = decrypt_message_popup_object.ids['encrypted_message'].text
......
......@@ -7,8 +7,10 @@ from kivy.uix.label import Label
from kivy.uix.popup import Popup
from kivy.lang import Builder
from modules.encryption.tools.all_tools.services import list_all_keys, export_single_key
from modules.encryption.tools.all_tools.utils import extract_key_uid_info
from modules.encryption.tools.all_tools.services import (
list_gpg_all_keys, export_single_key
)
Builder.load_file('./ui/encryption/all_tools/display_and_manage_key_pair.kv')
......@@ -44,6 +46,12 @@ class PrivateKeyPopup(Popup):
'''
class NoKeyPresent(BoxLayout):
'''
NoKeyPresent will be displayed in case if no key is present
'''
class DisplayAndManageKeyPair(BoxLayout):
'''
DisplayAndManageKeyPair helps integrate UI with helper functions
......@@ -51,7 +59,7 @@ class DisplayAndManageKeyPair(BoxLayout):
def __init__(self, **kwargs):
super(DisplayAndManageKeyPair, self).__init__(**kwargs)
all_keys = list_all_keys()
all_keys = list_gpg_all_keys()
self.populate_with_keys(
all_keys['all_public_keys'],
all_keys['all_private_keys']
......@@ -61,31 +69,39 @@ class DisplayAndManageKeyPair(BoxLayout):
'''
populate_with_keys displays all the available public and private keys
'''
for fingerprint, key_info in all_public_keys.items():
user_info = extract_key_uid_info(key_info['uids'][0])
key_column_box = KeyColumnBox()
key_info_label = KeyInfoLabel(
text='\n'.join(user_info.values())
)
key_column_box.add_widget(key_info_label)
fingerprint_text = fingerprint[:len(fingerprint) // 2] + '\n' +\
fingerprint[len(fingerprint) // 2:]
key_info_label = KeyInfoLabel(text=fingerprint_text)
key_column_box.add_widget(key_info_label)
key_box = KeyBox()
key_box.ids['Key_button'].id = fingerprint # pylint: disable=invalid-name
key_box.ids['Key_button'].bind(
on_press=self.display_public_key
)
key_column_box.add_widget(key_box)
if fingerprint in all_private_keys.keys():
if all_public_keys.items():
for fingerprint, key_info in all_public_keys.items():
user_info = extract_key_uid_info(key_info['uids'][0])
key_column_box = KeyColumnBox()
key_info_label = KeyInfoLabel(
text='\n'.join(user_info.values())
)
key_column_box.add_widget(key_info_label)
# Spliting fingerprint to multiple lines to make it better on the UI
# pylint: disable=invalid-name
FINGERPRINT_LENGTH_BY_HALF = len(fingerprint) // 2
fingerprint_text = fingerprint[:FINGERPRINT_LENGTH_BY_HALF] + '\n' +\
fingerprint[FINGERPRINT_LENGTH_BY_HALF:]
key_info_label = KeyInfoLabel(text=fingerprint_text)
key_column_box.add_widget(key_info_label)
key_box = KeyBox()
key_box.ids['Key_button'].id = fingerprint # pylint: disable=invalid-name
key_box.ids['Key_button'].id = fingerprint
key_box.ids['Key_button'].bind(
on_press=self.display_private_key
on_press=self.display_public_key
)
key_column_box.add_widget(key_box)
self.ids['scroll_view_box'].add_widget(key_column_box)
if fingerprint in all_private_keys.keys():
key_box = KeyBox()
key_box.ids['Key_button'].id = fingerprint
key_box.ids['Key_button'].bind(
on_press=self.display_private_key
)
key_column_box.add_widget(key_box)
self.ids['scroll_view_box'].add_widget(key_column_box)
else:
self.ids['scroll_view_box'].clear_widgets()
self.ids['scroll_view_box'].add_widget(NoKeyPresent())
@staticmethod
def display_public_key(*args):
......
......@@ -7,8 +7,9 @@ from kivy.uix.label import Label
from kivy.uix.popup import Popup
from kivy.lang import Builder
from modules.encryption.tools.all_tools.services import list_all_keys, encrypt_message
from modules.encryption.tools.all_tools.utils import extract_key_uid_info
from modules.encryption.tools.all_tools.services import (
list_gpg_all_keys, encrypt_message, create_key_listing_widget
)
Builder.load_file('./ui/encryption/all_tools/encrypt_a_message.kv')
......@@ -22,7 +23,8 @@ class KeyColumnBox(GridLayout):
class EncryptKeyBox(BoxLayout):
'''
EncryptKeyBox helps contain widgets and display them at the center of the box
EncryptKeyBox helps contain widgets and display them at the center of the
box
'''
......@@ -44,6 +46,12 @@ class EncryptMessagePopup(Popup):
'''
class NoKeyPresentEncrypt(BoxLayout):
'''
NoKeyPresentEncrypt will be displayed in case if no key is present
'''
class EncryptAMessage(BoxLayout):
'''
EncryptAMessage integrated UI with helper functions
......@@ -51,35 +59,22 @@ class EncryptAMessage(BoxLayout):
def __init__(self, **kwargs):
super(EncryptAMessage, self).__init__(**kwargs)
all_keys = list_all_keys()
all_keys = list_gpg_all_keys()
self.populate_with_keys(all_keys['all_public_keys'])
def populate_with_keys(self, all_public_keys):
'''
populate_with_keys displays all available public keys
'''
for fingerprint, key_info in all_public_keys.items():
user_info = extract_key_uid_info(key_info['uids'][0])
key_column_box = KeyColumnBox()
key_box = EncryptKeyBox()
key_box.ids['Key_button'].id = fingerprint # pylint: disable=invalid-name
key_box.ids['Key_button'].bind(
on_press=self.encrypt_message_popup
)
key_column_box.add_widget(key_box)
key_info_label = KeyInfoLabel(
text='\n'.join(user_info.values())
)
key_column_box.add_widget(key_info_label)
fingerprint_text = fingerprint[:len(fingerprint) // 2] + '\n' +\
fingerprint[len(fingerprint) // 2:]
key_info_label = KeyInfoLabel(text=fingerprint_text)
key_column_box.add_widget(key_info_label)
self.ids['scroll_view_box'].add_widget(key_column_box)
if all_public_keys.items():
for key_column_box in create_key_listing_widget(
self.encrypt_message_popup, all_public_keys, EncryptKeyBox,
KeyColumnBox, KeyInfoLabel
):
self.ids['scroll_view_box'].add_widget(key_column_box)
else:
self.ids['scroll_view_box'].clear_widgets()
self.ids['scroll_view_box'].add_widget(NoKeyPresentEncrypt())
@staticmethod
def encrypt_message_popup(*args):
......@@ -91,8 +86,8 @@ class EncryptAMessage(BoxLayout):
def get_encrypted_message(*args):
'''
get_encrypted_message receives all the data from input box in order to
fetch encrypted message
get_encrypted_message receives all the data from input box in order
to fetch encrypted message
'''
plain_message = args[1]
if plain_message:
......
'''
Service functions for encryption.tools module
'''
from subprocess import check_output
import gnupg
from modules.encryption.tools.all_tools.exceptions import GPGError
from modules.encryption.tools.all_tools.utils import extract_key_uid_info
GNUPG_HOME = 'gnupg_home'
IS_KEY_PRIVATE = True
def create_gnupg_object():
'''
Creating and returning GnuPG object
'''
gpg = gnupg.GPG(gnupghome=GNUPG_HOME)
gpg.encoding = 'utf-8'
return gpg
gpg_binary_path = check_output(
'which gpg2', shell=True).decode().strip('\n')
if gpg_binary_path:
gpg = gnupg.GPG(gnupghome=GNUPG_HOME, gpgbinary=gpg_binary_path)
gpg.encoding = 'utf-8'
return gpg
raise GPGError('''Please install gpg2 using your Operating System\'s
package manager''')
def create_key_pair(name, email, comment, expire_date, passphrase=''):
def create_gpg_key_pair(name, email, comment, expire_date, passphrase=''):
'''
Creating fresh public and private keys and returning key's fingerprint
'''
......@@ -41,35 +50,37 @@ def create_key_pair(name, email, comment, expire_date, passphrase=''):
raise GPGError(message=getattr(key, 'stderr'))
def list_all_keys():
def list_gpg_all_keys():
'''
Returning all public and private keys available in keyring
'''
gpg = create_gnupg_object()
# a key_map return a dictionary mapping key and subkey fingerprints to the
# corresponding key’s dictionary
return {
'all_public_keys': gpg.list_keys().key_map,
'all_private_keys': gpg.list_keys(True).key_map
'all_private_keys': gpg.list_keys(IS_KEY_PRIVATE).key_map
}
def export_single_key(keyid, passphrase=None):
def export_single_key(key_id, passphrase=None):
'''
Returning public or private key in ascii format
Returning public or private gpg key in ascii format
'''
gpg = create_gnupg_object()
if passphrase:
return gpg.export_keys(keyid, True, passphrase=passphrase)
return gpg.export_keys(keyid)
return gpg.export_keys(key_id, IS_KEY_PRIVATE, passphrase=passphrase)
return gpg.export_keys(key_id)
def encrypt_message(keyid, message):
def encrypt_message(key_id, message):
'''
Encrypting a message using a public key
Encrypting a message using a gpg public key
'''
gpg = create_gnupg_object()
encrypted_message_object = gpg.encrypt(message, keyid)
encrypted_message_object = gpg.encrypt(message, key_id)
if encrypted_message_object.ok:
return str(encrypted_message_object)
raise GPGError(message=encrypted_message_object.status)
......@@ -77,10 +88,43 @@ def encrypt_message(keyid, message):
def decrypt_message(message, passphrase):
'''
Decrypting a message using private key and passphrase
Decrypting a message using private gpg key and passphrase
'''
gpg = create_gnupg_object()
decrypted_message_object = gpg.decrypt(message, passphrase=passphrase)
if decrypted_message_object.ok:
return str(decrypted_message_object)
raise GPGError(message=decrypted_message_object.status)
def create_key_listing_widget(
message_popup, all_keys, key_box_object, key_column_box_object,
key_info_label_object
):
'''
This function yields a widget with key information everytime it's called
'''
for fingerprint, key_info in all_keys.items():
user_info = extract_key_uid_info(key_info['uids'][0])
key_column_box = key_column_box_object()
key_box = key_box_object()
key_box.ids['Key_button'].id = fingerprint
key_box.ids['Key_button'].bind(
on_press=message_popup
)
key_column_box.add_widget(key_box)
key_info_label = key_info_label_object(
text='\n'.join(user_info.values())
)
key_column_box.add_widget(key_info_label)
# Spliting fingerprint to multiple lines to make it better on the UI
# pylint: disable=invalid-name
FINGERPRINT_LENGTH_BY_HALF = len(fingerprint) // 2
fingerprint_text = fingerprint[:FINGERPRINT_LENGTH_BY_HALF] + '\n' +\
fingerprint[FINGERPRINT_LENGTH_BY_HALF:]
key_info_label = key_info_label_object(text=fingerprint_text)
key_column_box.add_widget(key_info_label)
yield key_column_box
'''
Utility functions for encryption.tools module
'''
import re
def clean_email(user_email):
......@@ -22,14 +21,15 @@ def clean_name(name):
def extract_key_uid_info(uid):
'''
extract_key_uid_info returns Name, Email and Comment from the key uid
uid format would be 'Shashank Kumar (This is a comment) <name@domain.com>'
'''
name = uid.split('(')[0].strip(' ')
name = clean_name(name)
email_pattern = re.compile(r'\<(.)*\>')
email = email_pattern.search(uid).group().strip('<> ')
email = uid.split('<')[1].split('>')[0]
email = clean_email(email)
comment_pattern = re.compile(r'\([\w\s]*\)')
comment = comment_pattern.search(uid).group().strip('() ')
comment = uid.split('(')[1].split(')')[0]
return {
'name': name,
......
......@@ -6,8 +6,8 @@ from datetime import datetime as dt
from modules.encryption.tools.all_tools.exceptions import GPGError
from modules.encryption.tools.all_tools.utils import (
clean_email,
clean_name)
clean_email, clean_name
)
def validate_name(name):
......@@ -46,9 +46,6 @@ def validate_comment(comment):
'''
if not comment:
raise GPGError('Enter Comment')
for part_comment in comment.split():
if not part_comment.isalpha():
raise GPGError('Incorrect Format')
return True
......
......@@ -49,8 +49,8 @@ class Tools(BoxLayout):
def populate_tools_menu(self):
'''
populate_tools_menu gathers the information about the tools and populates it on the tools
menu in GUI
populate_tools_menu gathers the information about the tools and
populates it on the tools menu in GUI
'''
difficulty_palette = {
'Beginner': (0.015, 0.588, 1, 1),
......@@ -73,8 +73,8 @@ class Tools(BoxLayout):
def import_tool_modules(self, tool_to_import):
'''
import_tool_modules try to import tool_to_import named module and also the class
ToolToImport
import_tool_modules try to import tool_to_import named module and also
the class ToolToImport
'''
module_name = tool_to_import
class_name = ''.join(tool_to_import.title().split('_'))
......@@ -85,8 +85,8 @@ class Tools(BoxLayout):
def open_tool(self, button_object):
'''
open_tool creates a new widget with option to get back to the tools menu and also
imports the selected tool module as the children widget
open_tool creates a new widget with option to get back to the tools menu
and also imports the selected tool module as the children widget
'''
tool_id = button_object.parent.parent.id
self.removed_tools_menu = self.children[0]
......@@ -97,8 +97,10 @@ class Tools(BoxLayout):
box_layout.orientation = 'vertical'
back_to_tool_menu = BackToToolsMenu()
back_to_tool_menu.ids['tool_title'].text = self.all_tools[tool_id]['title']
back_to_tool_menu.ids['tools_menu_button'].bind(on_press=self.back_to_tools_menu)
tool_title_object = back_to_tool_menu.ids['tool_title']
tool_title_object.text = self.all_tools[tool_id]['title']
back_to_tool_menu.ids['tools_menu_button'].bind(
on_press=self.back_to_tools_menu)
box_layout.add_widget(back_to_tool_menu)
box_layout.add_widget(self.all_tools[tool_id]['class']())
......@@ -106,7 +108,8 @@ class Tools(BoxLayout):
def back_to_tools_menu(self, button_object):
'''
back_to_tools_menu removes the tool widget and replaces tools menu
back_to_tools_menu removes the tool widget and replaces it with tools
menu
'''
self.remove_widget(button_object)
self.remove_widget(self.children[0])
......
......@@ -63,20 +63,25 @@ class Tutorials(BoxLayout):
tutorial_difficulty = value["difficulty"]
tutorial_color = difficulty_palette[tutorial_difficulty]
tutorial_box_widget = TutorialBox()
tutorial_box_widget.ids['tutorial_button'].bind(on_press=self.open_tutorial)
tutorial_box_widget.ids['tutorial_button'].bind(
on_press=self.open_tutorial)
tutorial_box_widget.id = key # pylint: disable=invalid-name
tutorial_box_widget.canvas.before.children[0].rgba = tutorial_color
tutorial_box_widget.ids['tutorial_box_title'].text = tutorial_title
tutorial_box_widget.ids['tutorial_box_difficulty'].text = tutorial_difficulty
t_d = tutorial_difficulty
tutorial_box_widget.ids['tutorial_box_difficulty'].text = t_d
self.ids['tutorials_menu'].add_widget(tutorial_box_widget)
@staticmethod
def get_tutorial_modules(tutorial_to_import):
'''
return requested tutorial by calling get_tutorial_widget of tutorial_parser
return requested tutorial by calling get_tutorial_widget of
tutorial_parser
'''
dir_name = os.path.dirname(__file__).split('modules')[1]
tutorial_to_import_path = 'modules' + dir_name + '/' + 'all_tutorials/' + tutorial_to_import
dir_name = os.path.dirname(__file__).split('new-contributor-wizard/')[1]
tutorial_to_import_path = os.path.join(dir_name,
'all_tutorials',