Created
April 7, 2010 21:59
-
-
Save andrzejkrzywda/359519 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def get_file_from_disk(self): | |
first_time = False | |
if not os.path.exists(CONFIG_DIR): | |
os.mkdir(CONFIG_DIR) | |
first_time = True | |
if not os.path.exists(DIARY_FILE): | |
file = open(DIARY_FILE, 'w') | |
file.close() | |
first_time = True | |
return open(DIARY_FILE, 'r'), first_time | |
---------- | |
PIERWSZY KROK | |
def get_file_from_disk(self): | |
if is_first_time() | |
os.mkdir(CONFIG_DIR) | |
file = open(DIARY_FILE, 'w') | |
file.close() | |
return file, True | |
else | |
return open(DIARY_FILE, 'r'), False | |
def is_first_time(self): | |
return not os.path.exists(CONFIG_DIR) or not os.path.exists(DIARY_FILE) | |
----- | |
DRUGI KROK | |
--- | |
def get_file_from_disk(self): | |
if is_first_time(): | |
return open(create_diary_file(), 'r'), True | |
else | |
return open(DIARY_FILE, 'r'), False | |
#ruby to byloby tak: | |
# return is_first_time() ? (open(create_diary_file(), 'r'), True) : (open(DIARY_FILE, 'r'), False) | |
def create_diary_file(self): | |
os.mkdir(CONFIG_DIR) | |
file = open(DIARY_FILE, 'w') | |
file.close() | |
return file | |
def is_first_time(self): | |
return not os.path.exists(CONFIG_DIR) or not os.path.exists(DIARY_FILE) | |
---- |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment