-
Notifications
You must be signed in to change notification settings - Fork 60
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
185 additions
and
0 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
class NatureLover: # Define a type of human being that loves nature | ||
def walk (self, dog): # The NatureLover walks the dog, really | ||
print ('\nC\'mon!') # \n means start on new line, \' means ' inside string | ||
dog.follow_me () # Just lets it escape | ||
|
||
class CouchPotato: # Define a type of human being that loves couchhanging | ||
def walk (self, dog): # The CouchPotato walks the dog, well, lets it go | ||
print ('\nBugger off!') # \n means start on new line | ||
dog.escape () # Just lets it escape |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
import bosses | ||
import dogs | ||
|
||
your_dog = dogs.Dog ('Wraff') # Instantiate dog, provide sound "Wraff" to constructor | ||
his_dog = dogs.Dog ('Howl') # Instantiate dog, provide sound "Howl" to constructor | ||
|
||
you = bosses.NatureLover () # Create yourself | ||
your_friend = bosses.CouchPotato () # Create your friend | ||
|
||
you.walk (your_dog) # Interface: walk dog, implementation: going out together | ||
your_friend.walk (his_dog) # Interface: walk dog, implementation: sending dog out |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
class Dog: # Define the dog species | ||
def __init__ (self, sound): # Constructor, named __init__, accepts provided sound | ||
self.sound = sound # Stores accepted sound into self.sound field inside new dog | ||
|
||
def _bark (self): # Define _bark method, not part of interface of dog | ||
print (self.sound) # It prints the self.sound field stored inside this dog | ||
|
||
def escape (self): # Define escape method | ||
print ('Hang head') # The dog hangs his head | ||
self._bark () # It then calls upon its own _bark method | ||
self._bark () # And yet again | ||
|
||
def follow_me (self): # Define escape method | ||
print ('Walk behind') # The dog walks one step behind the boss | ||
self._bark () # It then calls upon its own _bark method | ||
self._bark () # And yet again |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
import random # One of Python's many standard modules | ||
|
||
import bosses | ||
import dogs | ||
|
||
# Create a list of random bosses | ||
human_beings = [ # Start a so called list comprehension | ||
random.choice ( # Pick a random class | ||
(bosses.NatureLover, bosses.CouchPotato) # out of this tuple | ||
) () # and call its constructor to instantiate an object | ||
for index in range (10) # repeatedly, while letting index run from 0 to 9 | ||
] # End the list comprehension, it will hold 10 objects | ||
|
||
# Let them all walk a new dog with an random sound | ||
for human_being in human_beings: # Repeat the following for every human being in the list | ||
human_being.walk ( # Call implementation of walk method for that type of human being | ||
dogs.Dog ( # Construct a dog as parameter to the walk method | ||
random.choice ( # Pick a random sound | ||
('Wraff', 'Wooff', 'Howl', 'Kaii', 'Shreek') # fom this tuple of sounds | ||
) | ||
) | ||
) |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,106 @@ | ||
''' | ||
Copyright (C) 2014 - 2017 Jacques de Hooge, Geatec Engineering, www.geatec.com | ||
|
||
This program is free software. | ||
You can use, redistribute and/or modify it, but only under the terms stated in the QQuickLicence. | ||
|
||
This program is distributed in the hope that it will be useful, | ||
but WITHOUT ANY WARRANTY, without even the implied warranty of | ||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. | ||
See the QQuickLicence at www.qquick.org/licence.html for details. | ||
''' | ||
|
||
|
||
|
||
#==================================================================================================== | ||
# General options | ||
# All options have default value False | ||
#==================================================================================================== | ||
|
||
obfuscate_strings = True # Don't rely on this for sensitive information | ||
obfuscated_name_tail = '_opy_' # Will be added to all obfuscated names to avoid clashes with plain names | ||
plain_marker = '_opy_' # Strings or comments containing this marker will not be obfuscated | ||
pep8_comments = False # If True, only inline comments of the form <blank><blank>#<blank> | ||
# will be recognized | ||
|
||
|
||
|
||
#==================================================================================================== | ||
# Extensions of files that should be obfuscated | ||
# Typically these are files containing Python source code | ||
# Other files are just copied to the target directory | ||
#==================================================================================================== | ||
|
||
source_extensions = ''' | ||
py | ||
pyx | ||
''' | ||
|
||
|
||
|
||
#==================================================================================================== | ||
# Extensions of files that should neither be obfuscated nor copied to the target directory | ||
# Typically these are .pyc files, which could easily be decompiled, breaking obfuscation | ||
#==================================================================================================== | ||
|
||
skip_extensions = ''' | ||
pyc | ||
''' | ||
|
||
|
||
|
||
#==================================================================================================== | ||
# Fragments that, when occuring in the path of a file, will cause this file to be ignored | ||
# In other words, such files will neither be ofuscated nor copied | ||
# Use this to exclude complete directories from any processing by Opy | ||
# N.B. Use forward slashes rather than backslashes, also on Windows! | ||
#==================================================================================================== | ||
|
||
skip_path_fragments = ''' | ||
/test_skip_path_fragments/ # This fragment included for test purposes only | ||
''' | ||
|
||
|
||
|
||
#==================================================================================================== | ||
# Modules in sys.path containing identifiers that should not be obfuscated | ||
# Typically these are installed standard or 3rd party modules of which you have no source code | ||
# Use dotted names if needed, e.g. include both matplotlib and matplotlib.pyplot | ||
#==================================================================================================== | ||
|
||
external_modules = ''' | ||
re | ||
os | ||
sys | ||
errno | ||
keyword | ||
importlib | ||
random | ||
codecs | ||
shutil | ||
''' | ||
|
||
|
||
|
||
#==================================================================================================== | ||
# Relative path + name of Python source files containing identifiers that should not be obfuscated | ||
# Typically these are human readable settings files loaded and exec'ed at runtime by your program | ||
# Do not use this facility for files that are imported, that's what external_modules is for | ||
#==================================================================================================== | ||
|
||
plain_files = ''' | ||
opy_config.txt | ||
''' | ||
|
||
|
||
|
||
#==================================================================================================== | ||
# Extra identifiers and module names (as opposed to contents) that should not be obfuscated | ||
# Probably at least the names of your main modules (so not their filenames) go here | ||
#==================================================================================================== | ||
|
||
plain_names = ''' | ||
opy | ||
currentModule | ||
dog_walker | ||
''' |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
import random # One of Python's many standard modules | ||
|
||
import bosses | ||
import dogs | ||
|
||
# Create a list of random bosses | ||
humanBeings = [] # Create an emptpy list | ||
for index in range (10): # Repeat the following 10 times, index running from 0 to 9 | ||
humanBeings.append ( # Append a random HumanBeing to the list by | ||
random.choice ((bosses.NatureLover, bosses.CouchPotato)) () # randomly selecting its class | ||
) # and calling its contructor | ||
|
||
# Let them all walk a new dog with an random sound | ||
for humanBeing in humanBeings: # Repeat the following for every humanBeing in the list | ||
humanBeing.walk ( # Call implementation of walk method for that type of humanBeing | ||
dogs.Dog ( # Construct a new dog as parameter to the walk method | ||
random.choice ( # Pick a random sound | ||
('Wraff', 'Wooff', 'Howl', 'Kaii', 'Shreek') # fom this tuple of sounds | ||
) | ||
) | ||
) |