Limit list size by slicing

While making the bugzilla widget in Fedora Hubs, I encountered a situation where i had to store only the required N numbers of item in a list. This could be done by using a while loop or an if condition but I learnt another way of doing this.

Example:

>>> country = []
>>> country = (country + [“india”])
>>> country = (country + [“pakistan”])
>>> country = (country + [“japan”])
>>> country
[‘india’, ‘pakistan’, ‘japan’]
>>> country = (country + [“australia”])[:2]
>>> country
[‘india’, ‘pakistan’]

This makes sure that the list size never exceeds 2.

Limit list size by slicing

My contributions in Fedora-Hubs

I have worked on 5 issues in fedora-hubs uptil now:

  1.  Pagure Issues Widget
  2.  Pagure Pull Request Widget
  3.  Github Issues Widget
  4.  Github Pull Request Widget
  5.  Bugzilla Widget

Fedora-Hubs source code:

https://pagure.io/fedora-hubs/

The request module:

To extract information from Pagure, Github or Bugzilla, I used requests Python module.

Get more information on Request module here.

Install it using pip:

pip install requests

Steps involved

  1. Using requests module, extract the data from the api of website.
  2. Make sure you pass the appropriate username, project name in the URL.
  3. The return value of API calls is in JSON format.
  4. Now, simply using the basic Python slicing and indexing, extract the required data (e.g. id, issue/PR title) from the JSON data.
  5. Put this data (e.g. id, issue/PR title) appropriately in a data structure (I used a combination of list and dictionary)
  6. Return the data structure.

Pagure Widgets

This is the main page of Pagure: pagure.io

This is the documentation of API of Pagure: https://pagure.io/api/0/

Example of a GET request URL:

  1. To list a project’s Issues: https://pagure.io/api/0/<name of the project>/issues
  2. To list a project’s Pull Requests: https://pagure.io/api/0/<name of the project>/pull-requests

These are the screenshots:

pagureissues
Pagure Issues Widget for Fedora-Hubs
pagurepr
Pagure Pull Requests Widget for Fedora-Hubs

Github Widgets

This is the documentation of API of Github: https://developer.github.com/v3/

Although there are specific github modules in Python. But since the issue involved only extraction and display of data, it can be done by using requests module itself.

Example of GET request URL:

  1. https://api.github.com/repos/<name of the organisation>/<name of the repository>/issues
  2. https://api.github.com/repos/<name of the organisation>/<name of the repository>/pulls

Example:

https://api.github.com/repos/fedora-infra/fas/issues

https://api.github.com/repos/fedora-infra/fas/pulls

These are the screenshots:

githubissues
Github Issues Widget for Fedora-Hubs
githubpr
Github Pull Requests Widget for Fedora-Hubs

Bugzilla Widget

This is the Widget on which I am currently working on.

For this widget, I need one more module pkgwat.api module.

Get more information on pkgwat.api here.

Install it using pip:

pip install pkgwat.api

In this issue following steps occur:
1. Using requests module extract the packages of a specific user from fedora project api. This is the URL: https://admin.fedoraproject.org/pkgdb/api/packager/package/<username&gt;

2. Pass each package name to pkgwat.api.bugs which returns all the issues of that particular package.

3. Store issue details(id, title) properly in a data structure.

4. Return the data structure

Screenshot from 2016-03-06 20-40-28
Bugzilla Issues Widget for Fedora-Hubs

Want to contribute to fedora-Hubs? checkout my blog on Fedora-Hubs.

My contributions in Fedora-Hubs

Fedora-Hubs

 

 

The Fedora.Next concept

This is where the idea of Fedora-Hubs evolved from. There are three components to this proposal:
1. Fedora “Brochure” Site
2. A Fedora User Support Site
3. A Fedora “Community Hub” —→ The idea of Fedora-Hubs

Read the whole idea about Fedora.Next here

The Fedora-Hubs

Fedora Hubs is a modern, web based Fedora activity center.

Need of Fedora-Hubs

1. Currently, the fedora web presence involves:
– mailing lists
– IRC

2. It become daunting for new Fedora contributors to keep a track of various projects and teams they’re involved with in Fedora. Fedora-Hubs provides them a workflow.

3. Example:
Sometimes, new contributors have trouble using IRC because of the available chat systems they’re accustomed to. With the IRC widget of Fedora-Hubs, new contributors can use IRC without having to install anything.

4. It is like a social network for Fedora contributors.

5. Existing contributors can use it to collect their:
– ideas
– information
and keep a track of their activities.

Getting Started with Fedora-Hubs

The source code of Fedora Hubs resides in Pagure. You can find the source code here.

Fedora-Hubs uses Fedora Accounts System (FAS) to contribute as well as use. You can create a FAS acoount here.

Features in Fedora-Hubs

1. List of open tickets widget
2. General Activity Stream
3. Easy fixes

Checkout the issues page for a list of expected features.

IRC Channels

1. #fedora-apps:
Most of the discussion takes place here

2. #fedora-hubs:
a specific channel for Fedora Hubs

3. #fedora-design

Subscribe to mailing list here

Get more information from

1. Máirín Duffy:
blog: http://blog.linuxgrrl.com/
IRC nick: mizmo
Twitter: @mairin

2. Meghan Richardson:
blog: https://meghanrichardson.wordpress.com/
twitter: @meghanathema

3. Ryan Lerch:
blog: http://www.ryanlerch.org/blog/
IRC nick: ryanlerch

4. Ralph Bean:
IRC nick: threebean

5. Pierre Yves-Chibon:
IRC nick: pingou

6. Remy Decausemaker:
IRC nick: decause

Relevant Resources

1) Fedora-Hubs Wiki:
https://fedoraproject.org/wiki/Fedora_Hubs

2) A collection of all the blogs on Fedora-Hubs by Máirín Duffy:

3) The blog of Meghan Richardson where you can get a lot of detailed information on Fedora-Hubs:
https://meghanrichardson.wordpress.com/

4) Post-Its on Fedora-Hubs by Ryan Lerch:
postits.jpg

5) A news article on Fedora-Hubs:
http://www.pcworld.com/article/3038353/linux/fedora-project-leader-matthew-miller-reveals-whats-in-store-for-fedora-in-2016.html

6) A video of Máirín Duffy & Meghan Richardson on “Enabling new contributors with Fedora Hubs” in Flock 2015

7) A Brainstorm Session on “Enabling New Contributors in Fedora”:

8) A video on “Fedora Hubs Hackfest 2015”:

9) A PiratePad link to the discussion on Fedora-Hubs:
http://piratepad.net/fedora-hubs-mar2015

10) Links to all mockup resources:

a) The github source of all mockups:
https://github.com/fedoradesign/fedora-hubs

b) http://fedoradesign.github.io/fedora-hubs/mockup.html

Checkout “My contributions to Fedora-Hubs”.

Fedora-Hubs