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
class StrAttrValidation(object): | |
def __init__(self): | |
self._dict = dict() | |
def __set__(self, instance, value): | |
if not isinstance(value, str): | |
raise AttributeError('Only Str type valid') | |
self._dict[instance] = value.title() | |
def __get__(self, instance, value): |
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
class StrAttrValidation(object): | |
def __init__(self): | |
self._dict = dict() | |
def __set__(self, instance, value): | |
self._dict[instance] = value.title() | |
def __get__(self, instance, value): | |
return self._dict[instance] |
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
emp = Employees('stephen', 'bournemouth', 30) | |
for key, value in emp.__dict__.items(): | |
print('{} = {}'.format(key, value)) | |
print('###################################') | |
emp(location='newloc') | |
for key, value in emp.__dict__.items(): |
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
emp = Employees('stephen', 'bournemouth', 30) | |
for key, value in emp.__dict__.items(): | |
print('{} = {}'.format(key, value)) | |
emp('Simon') | |
print('#####################################') | |
for key, value in emp.__dict__.items(): |
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
class Employees(object): | |
def __init__(self, name, location, age): | |
self._name = name | |
self._age = age | |
self._location = location | |
# attribute re-assignment | |
def __call__(self, *args, **employee_info): | |
if hasattr(self, '_name') and len(args) == 1: | |
self._name = args[0] |
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
class Employees(object): | |
def __init__(self, name, location, age): | |
self._name = name | |
self._age = age | |
self._location = location | |
emp = Employees('stephen', 'bournemouth', 30) | |
for key, value in emp.__dict__.items(): | |
print('{} = {}'.format(key, value)) |
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
<!-- | |
...if block above... | |
--> | |
{% else %} | |
<h1>Explore BacGenomePipeline</h1> | |
{% with messages = get_flashed_messages(category_filter=['success']) %} | |
{% if messages %} | |
{% for message in messages %} | |
<h5 class="col-lg-4 col-sm-12 alert alert-success" role="alert" >{{message}}</h5> |
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
@app.route('/logout') | |
@login_required | |
def logout(): | |
logout_user() | |
flash('You have successfully logged out', category='success') | |
session['username'] = None | |
return redirect(url_for('landing_page')) |
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
<div class="container"> | |
<div class="carousel-caption text-start"> | |
{% if active_user %} | |
<h1>Welcome {{ active_user }}</h1> | |
<h1>Explore BacGenomePipeline</h1> | |
<p>Raw reads to annotated bacterial Genome</p> | |
{% else %} | |
<h1>Explore BacGenomePipeline</h1> | |
{% with messages = get_flashed_messages(category_filter=['success']) %} |
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
@app.route('/', methods=['GET', 'POST']) | |
def landing_page(): | |
try: | |
active_user = session['username'] | |
active_user = re.findall('[A-Z][^A-Z]*', active_user) | |
active_user = ' '.join(active_user) | |
return render_template('landing_page.html', active_user=active_user) | |
except (KeyError, TypeError): | |
return render_template('landing_page.html') |