Feeds

Evolving Web: Drupal 8 Migration: Migrating Basic Data (Part 1)

Planet Drupal - Mon, 2017-01-16 12:35

A tutorial on migrating basic data to a Drupal 8 site using the migrate module and related modules.

read more
Categories: FLOSS Project Planets

Web Wash: How to Manage Media Assets in Drupal 8

Planet Drupal - Mon, 2017-01-16 12:30
Everyone has their own definition of media management. In this tutorial, I'm going to focus on three parts: Storing assets, Embedding assets, Browsing assets. I want to give users the ability to create a media assets. Then have a button in the editor which they can use browse assets and then embed them. We'll utilize three modules to handle this: Media Entity, Entity Embed and Entity Browser.
Categories: FLOSS Project Planets

PyTennessee: PyTN Profiles: Brian Pitts and Avrio Analytics

Planet Python - Mon, 2017-01-16 11:23


Speaker Profile: Brian Pitts (@sciurus)

Brian studied political science in college, but when his thesis contained more python code than prose it was clear where his true loyalties lay. He’s worked in operations roles for the past eight years and currently carries the pager for eventbrite.com.

He lives in East Nashville with his wife, son, two cats, and collection of 1990s Unix workstations.

Brian will be presenting “Stability and Capacity Patterns” at 3:00PM Saturday (2/4) in the Auditorium. At Eventbrite, engineers are tasked with building systems that can withstand dramatic spikes in load when popular events go on sale. There are patterns that help us do this. Come learn about these patterns, how Eventbrite has adopted them, and how to implement them within your own code and infrastructure.

Sponsor Profile: Avrio Analytics (@avrioanalytics)

Avrio is the complete customer life cycle SaaS tool. From finding your ideal customer, to closing the deal and keeping them interested, let our cognitive AI engine add more power to your marketing and sales team. Tomorrow is here.

Categories: FLOSS Project Planets

Weekly Python Chat: Teaching Python & Python Tutor

Planet Python - Mon, 2017-01-16 11:00

This week we'll be chatting with special guest Philip Guo about pythontutor.com, a web application he made for visualizing Python code. We'll talk about how PythonTutor can be used for teaching and learning Python.

Categories: FLOSS Project Planets

Drupal core announcements: Drupal 8 Migrate API is in beta

Planet Drupal - Mon, 2017-01-16 10:31

Drupal 8.0.0 replaced the earlier, in-place upgrade procedure for major version upgrades with a migration-based solution for core and contributed modules. Several modules serve this need in core: The Migrate module provides a general API for migrations, the Migrate Drupal module provides API support for Drupal-to-Drupal migrations, and the Migrate Drupal UI module offers a simple user interface to run migrations from older Drupal versions.

A lot of work has gone into making migrations more complete since the initial 8.0.0 release, including for multilingual sites with various configurations. Drupal-to-Drupal migrations are still not wholly complete (especially for Drupal 7 sources). However, lots of real-life use has validated the choices we made with the base Migrate API, and key architectural improvements have been completed already. An increasing number of contributed modules rely on it for their migrations.

Based on this stability and success, the Migrate subsystem maintainers and Drupal release managers have agreed the Migrate API (the Migrate module) now has beta stability! The change took effect in Drupal 8.2.x with 8.2.5 and will apply to 8.3.0 onwards as well.

What does this mean for sites and developers relying on the Migrate API?

Beta experimental modules are considered API- and feature-complete and beta modules are subject to the beta allowed changes policy. This means that module and migration developers can rely on the API remaining stable from now on! This also means that the focus with Migrate API is on fixing critical issues as well as bug fixes and contributed project blockers, if they are non-disruptive, or if the impact outweighs the disruption.

Note that Migrate Drupal and Migrate Drupal UI are still alpha stability, so API changes may still happen in these modules. Completing the Drupal-to-Drupal migration path and getting Migrate Drupal to beta stability is the next priority, so your help with missing and incomplete migrations is welcome!

If you want to get involved, the migration team is meeting every week at alternating times. The team has Google Hangouts at Wed 1pm UTC or Thu 1am UTC on an alternating weekly schedule. The #drupal-migrate IRC channel is also used as a backchannel.

Categories: FLOSS Project Planets

Sooper Drupal Themes: Introducing Glazed Builder: A Monumental Update By SooperThemes

Planet Drupal - Mon, 2017-01-16 09:53

2017 is going to be an incredible year for SooperThemes and for you! We kick off with the first official major version update for our drag and drop builder! Today we introduce you to Glazed Builder 1.1.0. We have rebranded Carbide Builder to Glazed Builder and developed some major new features, including entity revisions, full support for filtered contextual views and RGBA color sliders!

This is a monumental update. Glazed Builder is currently not only the greatest and fastest drag and drop builder for Drupal but also a very competitive product in the wider site building landscape. Going forward we'll not only develop more features and designs but we'll also start developing even more complete and complex turn-key Glazed demos. In addition this release marks the start of our Drupal 8 upgrade sprint. Yes, you heard that right, with the D8Media initiative aiming to add much needed Media improvements in Drupal 8.3 we feel like now is the right time. 

Try Glazed Builder Now

The Admin demo is free, no card required!

Redesigned for 2017

Glazed Builder has a fresh look that is designed for fast intuitive site-building. The speed of an interface isn't just about fast code, it's very much about fast design too. The new controls are all-white and while animation is used on the drop shadows the actual controls appear and respond immediately.

The colors and branding are matched to the Glazed brand, to emphasize the uniform experience you get when you combine our Glazed Theme with the builder. That said, Glazed Builder is still an independent module that can work with any Drupal theme! 

Views with Contextual Filters

Perfect if you're making a magazine website or more serious blog or commerce website! Now you can design taxonomy term or e-commerce pages with dynamic views displays. It is now fully supported to load views in drag and drop pages, override their filters and pagers in Glazed Builder, and let these views take default arguments based on url parts.

This feature is not just awesome for magazine websites but also for government websites, intranets, communities... Basically anyone who builds websites with large amounts of structured content will love this update.

Better Equal Heights Rows And Vertical Centering, RGBA Color

Having an alpha slider on every color setting in Glazed Builder allows more creative freedom for designers and makes it easier for site builders to implement designs that use translucent elements. We also improved equal heights rows by replacing the old jQuery trick with faster, reliable Flexbox CSS. In addition we enriched the column element with a Vertical Centering option. This let's you add vertical centering to columns independently of sibling columns. 

Saving Revisions

Some updates are invisible: Glazed Builder now automatically detects entity types that support revisions and will create new revisions when saving to fields on these entities. It doesn't matter if your field is on a node, bean block or custom entity. It doesn't even matter if you have have 10 Glazed Builder instances in one page, saving to multiple entities in the backend. It all just works and with revisions you'll easily undo those regrettable changes that seemed right in the spur of the moment.

​ Goole AMP

Google AMP is seeing more and more adoption and we integrated Glazed Builder with the Drupal AMP module. AMP is very restrictive so it won't allow fancy elements like circle charts and image comparison widgets but it should work fine with non-interactive markup generated by Glazed Builder. We welcome feedback from AMP experts on how to further extend AMP support!

Glazed Theme 2.6.0

While this releases focuses on the Glazed Builder update, Glazed Theme also received new features and consequently a major version bump to 2.6.0. Less spectaculary but still very useful: A Import/Export interface was added to the Glazed Theme Settings interface. All those settings that collectively make up your sites' unique design can now easily be copy-pasted between environments, or into a new subtheme .info file.

Drupal 8 Themes and Builder

        As a subscription Drupal theme shop, we really focus on building long-term relationships with our customers and that's why we carefully chose important moments that affect the products we make and maintain. Choosing the right moment to make the D8 move was hard, because Drupal 7 is just so good that it was hard for Drupal 8 to take the crown. 

        From my perspective, this moment is the release of Drupal 8.3 with contrib in great shape, improved media handling, and hopefully a media browser in core! The moment that it no longer makes sense for anyone to start a Drupal 7 website is approaching and we're going to make sure all our products are running smoothly on Drupal 8 by that time.

              source

              For more details about this update:

                    Try Glazed Builder Now

                    The Admin demo is free, no card required!

                    Categories: FLOSS Project Planets

                    Raphaël Hertzog: Freexian’s report about Debian Long Term Support, December 2016

                    Planet Debian - Mon, 2017-01-16 09:39

                    Like each month, here comes a report about the work of paid contributors to Debian LTS.

                    Individual reports

                    In December, about 175 work hours have been dispatched among 14 paid contributors. Their reports are available:

                    Evolution of the situation

                    The number of sponsored hours did not increase but a new silver sponsor is in the process of joining. We are only missing another silver sponsor (or two to four bronze sponsors) to reach our objective of funding the equivalent of a full time position.

                    The security tracker currently lists 31 packages with a known CVE and the dla-needed.txt file 27. The situation improved a little bit compared to last month.

                    Thanks to our sponsors

                    New sponsors are in bold.

                    No comment | Liked this article? Click here. | My blog is Flattr-enabled.

                    Categories: FLOSS Project Planets

                    Doug Hellmann: shelve — Persistent Storage of Objects — PyMOTW 3

                    Planet Python - Mon, 2017-01-16 09:00
                    The shelve module can be used as a simple persistent storage option for Python objects when a relational database is not required. The shelf is accessed by keys, just as with a dictionary. The values are pickled and written to a database created and managed by dbm . Read more… This post is part of … Continue reading shelve — Persistent Storage of Objects — PyMOTW 3
                    Categories: FLOSS Project Planets

                    ThinkShout: Using Google Docs and Migrate to Populate Your Drupal Site, Part 2

                    Planet Drupal - Mon, 2017-01-16 09:00

                    In Part 1, I talked about using Google Docs + Migrate to populate your site. Now we’re going to do that with the Migrate Google Sheets module. Below, I’ll provide the steps to get your own migration up and running, but if you prefer to experiment with a working example, check out a demo of the Migrate Google Sheets Example module (provided as a submodule within Migrate Google Sheets). All content on that site was built using this example Google Sheet.

                    Setup: Install the Module

                    If you’ve already got a Drupal 8 site up and running, you can install the module in any of the normal ways. I’m assuming here that you have access to the site using Drush, as it’s not possible to run migrations through anything but the command line at this time. At ThinkShout, we use composer to build our site distributions, and have a repo for building the demo site here.

                    Step 1: Creating Your Custom Migration Module

                    The easiest way to get started on your own set of migrations is to copy the migrate_google_sheets_example submodule and rename it something of your own. Let’s say we rename it “my_migration.” Follow these steps:

                    1. Rename your .install file to “my_migration.install”, and change the function migrate_google_sheets_example_uninstall to “my_migration_uninstall”.
                    2. Delete the helper submodule “migrate_google_sheets_example_setup” entirely – that is just necessary to build the content types required for the example module, but you shouldn’t need it for your migration module.
                    3. Rename your migrate_google_sheets_example.info.yml as “my_migration.info.yml” and open it up. At the very least, you’ll want to change the name of the migration to “name: my_migration” but you’ll also likely wish to remove the migrate_google_sheets:migrate_google_sheets_example_setup dependency. Mine ended up looking like this:
                    name: my_migration type: module description: My Migrations core: 8.x package: Migrate dependencies: - migrate_plus - migrate_tools - migrate_google_sheets - redirect

                    When completed, your module structure should look like this:

                    You are now ready to enable your My Migrations module. (Make sure you disable the migrate_google_sheets_example module first, if you’d previously enabled that!)

                    Step 2: Create Your Spreadsheet

                    Assuming you have the Game and Landing page content types, you could now run the migrations in your “My Migrations” module and it will pull the data from the Google Sheet.

                    But since you don’t have permissions to edit that sheet, you’re going to need to copy the existing sheet and create your own to do any customizations.

                    When this is done, you’ll get a url like this:

                    https://docs.google.com/spreadsheets/d/YourLongHashIDHere where YourLongHashIDHere is your feed key.

                    Now you’ll need to publish your new spreadsheet. This is an option under “File” -> “Publish to the web”

                    To verify that your migration module will be able to see the Google sheet, try opening an anonymous browser window and visiting the Feed version of the url, whose format is this:

                    https://spreadsheets.google.com/feeds/list/YourLongHashIDHere/SHEET/public/values?alt=json

                    If visiting that URL throws out a bunch of json, you’re ready to start migrating!

                    But of course, your current set of migration files still point to the old feed. In the my_migrations/config/install folder, you’ll need to find all instances of our feed string (1spS1BeUIzxR1KrGK2kKzAoiFZii6vBHyLx_SA0Sb89M) and replace them with your feed string.

                    Step 3: Decide Which Migrations to Keep

                    The Migrate Google Sheets Example module provides one Migration Group (games_example) and 6 Migrations. Depending on your site configuration, some of these might be useful, like the menu_links and the blocks migrations, and some of them will not be so useful (like the node_game migration, likely). This is a good time to trim or modify any migrations that aren’t going to be useful for your Drupal site. That being said, here are a few things that the sample migrations demonstrate:

                    • Block UUIDs: When you place a block using the Block Layout screen, the block’s UUID is saved in config. If you’re running a migration over and over, your block’s ID will iterate on its own, but the UUID can remain constant if you add it to the migration. In the demo site, this allows us to create a persistent CTA block in the header.

                    • Menu Links parents: You can specify that a menu link item has a parent from within the current migration. This lets us say /bohnanza and /hanabi are children of /games
                    • Page and Game redirects: These sheets demonstrate how to add the redirect from the url of content on an old site to the new home right in the content sheet. Try going to https://live-mgs-demo.pantheonsite.io/that-fireworks-game and see where you end up.
                    • Related content as strings or ids: On the Page sheet, we have a reference to the “Related games” for the given page. This is an entity reference which we could fill with a couple of things. We could refer to the ID of the related games, as they are stored in the Games sheet, or we could do what we’ve done here and use the migrate_plus plugin “entity_lookup” to search for the related game node by name. As long as there is a Game node called Bohnanza, we’ll always link to the right one. This is particularly useful with Term references, where the name of the item ideally remains constant.

                    • Game downloadable file: Games have associated images, which are files hosted externally to the spreadsheet. In order to relate my game content to its image, I need to download the image, get it into the file_managed database table (creating a file entity) and THEN relate that entity to the current node. This is done with the following lines in the “node_games” migration:
                    public_file_directory: plugin: default_value default_value: 'public://' public_file_uri: plugin: concat delimiter: '' source: - @public_file_directory - imagefilename field_image/target_id: - plugin: file_copy source: - image - @public_file_uri - plugin: entity_generate field_image/alt: imagealt field_image/title: imagetitle

                    You can keep as many or as few of the migration files as you’d like. You can also create new ones.

                    Step 4: Tell Drupal About Your Changes

                    Drupal 8 only sees the changes you’ve made to your migration yml files when you first install the module. That means that you need to uninstall and reinstall the module to make new changes show up. ThinkShout has a Robo script that does this, but the same thing can be done in Drush:

                    drush mr --all # Rolls back all migrations drush pmu my_migration -y # Disables my migration module drush en my_migration -y # Enable my migration module drush ms # Displays my current migration status

                    You can also string these together as one line:

                    drush mr --all && drush pmu my_migration -y && drush pmu my_migration -y && drush ms Step 5: Run your migrations

                    This part is simple. To run all migrations, it’s a quick drush command:

                    drush mi --all

                    If you’d like to find out about all the possible options for the migrate-import command, you can run

                    drush help mi

                    You can also see your list of migration groups at /admin/structure/migrate, and you can review your migrations by clicking “List Migrations.” The resulting page will give you the same output, more or less, that you get from running a drush ms.

                    These pages are helpful to know about, as they give you an easy place to find errors logged during the migration process. However, you can’t currently run a migration from the UI (although there is an issue for this).

                    Gotchas

                    But before we close, I do want to acknowledge some challenges we’ve seen in this approach.

                    Sad fact #1: HTML in a spreadsheet is ugly.

                    Google Spreadsheets don’t let you make your rows smaller than the number of line breaks in a cell. So if you have pretty html with a bunch of line breaks, your row might be too tall to fit on your screen. People have some clever workarounds for this, but so far we’ve not implemented any.

                    Sad fact #2: Sheet order matters (right now)

                    Maintaining the order of sheets isn’t top on everyone’s minds as they’re making changes to a spreadsheet, especially when duplicating tabs. Migrate Google Sheets asks for each sheet based on tab order. If I make a copy of the Page tab, the Game tab is now the fourth tab instead of the third tab.

                    As it stands now, the module will happily request columns that don’t exist on the third tab and then fail in puzzling ways.

                    There is currently only one issue in the issue queue for the Migrate Google Sheets module, and it’s to fix this.

                    Sad fact #3: Google sheets must be publicly viewable to work (again, right now)

                    As the module exists right now, there’s no authentication involved, so any migrated content must be publicly viewable. Google authorization is possible with Oauth2, but that is not currently implemented.

                    Conclusion

                    Thanks for following along! I hope you found this series helpful. And don’t forget to visit the Migrate Google Sheets issue queue if you find any bugs, have an idea for a feature, or need help!

                    Categories: FLOSS Project Planets

                    Mike Driscoll: PyDev of the Week: Cameron Simpson

                    Planet Python - Mon, 2017-01-16 08:30

                    This week we welcome Cameron Simpson as our PyDev of the Week. Cameron is the co-author of PEP 418 – Add monotonic time, performance counter, and process time functions and the author of PEP 499 – python -m foo should bind sys.modules[‘foo’] in addition to sys.modules[‘__main__’]. He is also a core Python developer and enthusiast. You can check out some of his projects on bitbucket. Let’s take a few moments to get to know him better!

                    Can you tell us a little about yourself (hobbies, education, etc):

                    I’ve been a programming nerd since I was about 15, and I’ve got a BSc in Computer Science. I’m a somewhat lapsed climber and biker; I still have a motorcycle and try to use it but circumstances interfere; I’m trying to resume some indoor climbing too. I’m spending a fair amount of time on a small farm, and teleworking from there part of the time; I’ve been fortunate to find work where that is possible.

                    Why did you start using Python?

                    In 2004 I’d been intending to learn Python for a while, maybe over a year, but kept putting it off because of my huge personal Perl library that caused me to resist change – a personal library means you’ve got this kit of things that make the specific things you tend to do easier.

                    I think in 2004 I decided to dig myself out o this hole by reimplementing core stuff from my perl lib in Python so that I could write Python scripts to work with my existing data. Also that year a friend was dealing with a stripped down Jython platform in WebSphere, so there was some Pythoning there too implementing some stuff.

                    From that point on things snowballed as my core working Python stuff grew and Python was clearly a better language.

                    What other programming languages do you know and which is your favorite?

                    Python is my present favourite, and has been for some years. It has a nice balance of power and clarity, and I continue to like the design decision that go into it.

                    The languages I use regularly and fluently include Python, the Bourne shell, sed and awk and their friends. I like to use the “smallest” tools for a task that succinctly express a solution, so I tend to switch up from things like sed to shell to Python, or a mix.

                    I’m competent in various other languages; I’m also using Go and PHP and a little JavaScript in my current job. I started in BASIC, know (or knew) a few assembly languages, C, Java, SQL, Prolog, Pascal, SR, Modal, and have used several others at various times.

                    What projects are you working on now?

                    Several, mostly to scratch personal itches; you can see almost all of it at bitbucket; it looks like all Python but almost my entire bin directory scripts are there too. In terms of “projects”: myke, my make replacement; vt, a content addressed storage system (after the style of https://en.wikipedia.org/wiki/Venti but not the same) with a FUSE filesystem layer on top and ways to connect storage pools together; yet another MP4 parser, partly to aid inspecting and controlling media metadata and partly intended as a proof of concept for the format specific blockifier side of the storage system; tools for accessing my PVR’s recordings; mailfiler, my mail filing tool; maildb and nodedb, ah doc node/attribute storage, usually based off shared CSV files; the scripts and library files underpinning these; later, which I use instead of the futures library. I’m trying to get more of the library modules into PyPI.

                    Which Python libraries are your favorite (core or 3rd party)?

                    I think BeautifulSoup is an amazing tool. I love the threading facilities in Python’s stdlib. When I use it, I think SQLAlchemy is a lovely way to interact with SQL (I avoid the ORM side).

                    What is your take on the current market for Python programmers?

                    Regrettably I don’t have string opinions here. I’m enough of a generalist to not need to seek specific “python programming” niches (though last time around, that is somewhat what I was seeking). Of course the flip side to being a generalist is that I can apply Python to many needs, giving me an excuse to use it!

                    Is there anything else you’d like to say?

                    Like others, I think the Python community is great. I mostly interact with it via python-list, and I’m constantly heartened by the effort people put into staying constructive instead of descending into conflict as is too easy. In few other fora are people as willing to apologise for ill thought opinions or behaviour, as earnest in their attempts to justify their positions with evidence, reason and experience, and as prepared to accept that others’ experiences and needs are different from their own.

                    Thanks for doing the interview!

                    Categories: FLOSS Project Planets

                    PythonClub - A Brazilian collaborative blog about Python: Abrangência de Listas e Dicionários

                    Planet Python - Mon, 2017-01-16 07:37

                    A utilização de listas em Python é algo trivial. A facilidade provida pela linguagem aliada a simplicidade da estrutura de dados list a torna, ao lado dos dicionários dict, uma das estrutura de dados mais utilizadas em Python. Aqui neste tutorial irei compartilhar algo que aprendi trabalhando com listas e dicionário em Python, mais especificamente no que diz respeito a abrangência de listas (e dicionários).

                    Abrangência de listas

                    A abrangência de listas, ou do inglês list comprehensions, é um termo utilizado para descrever uma sintaxe compacta que o Python nos oferece para criamos uma lista baseada em outra lista. Pareceu confuso? Ok, vamos aos exemplos!

                    Exemplo 1

                    Vamos suport que temos a seguinte lista de valores:

                    valores = [1, 2, 3, 4, 5]

                    Queremos gerar uma outra lista contendo o dobro de cada um desses números, ou seja,

                    [2, 4, 6, 8, 10]

                    Inicialmente, podemos montar o seguinte código como solução:

                    # Recebe o nosso resultado valores_dobro = [] for val in valores: valores_dobro.append(val * 2) print(valores_dobro) >>> [2, 4, 6, 8, 10]

                    A solução acima é uma solução simples e resolve nosso problema, entretanto para algo tão simples precisamos de 4 linhas de código. Este exemplo é uma situação onde a abrangência de lista pode ser útil. Podemos compactar a criação da lista valores_dobro da seguinte maneira:

                    valores_dobro = [valor*2 for valor in valores]

                    Bacana não? O exemplo seguinte podemos incrementar mais o exemplo acima.

                    Exemplo 2

                    Vamos supor que desejamos criar uma lista onde apenas os valores pares (resto da divisão por 2 é zero) serão multiplicados por 2. Abaixo temos a nossa lista de valores:

                    valores = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]

                    Assim como no exemplo anterior, podemos resolver utilizando um algoritmo básico.

                    # Lista que recebera o nosso resultado valores_dobro = [] for valor in valores: if valor % 2 == 0: valores_dobro.append(valor * 2) print(valores_dobro) >>> [4, 8, 12, 16, 20]

                    Podemos também resolver o mesmo problema utilizando as funções nativas map e filter:

                    valores_dobro = map(lambda valor: valor * 2, filter(lambda valor: valor % 2 == 0, valores))

                    Muito mais complicada não é? Apesar de resolver nosso problema, expressões como a acima são difíceis de ler e até mesmo de escrever. Em casos como esse, podemos novamente compactar nosso algoritmo utilizando a abrangência de lista.

                    valores_dobro = [valor * 2 for valor in valores if valor % 2 == 0]

                    Muito mais simples, não? Vamos para o próximo exemplo.

                    Exemplo 3

                    De maneira semelhante a lista, nós também podemos aplicar a abrangência em lista e dicionários. Segue um exemplo onde temos o seguinte dicionário:

                    dicionario = {'a': 1, 'b': 2, 'c': 3, 'd': 4, 'e': 5, 'f': 6}

                    Vamos criar um segundo dicionário contendo apenas as chaves que são consoantes, ou seja, b, c, d e f, sendo que o valor para cada uma dessas chaves deve ser o dobro do valor armazenado na respectiva chave do dicionário original. Complicado? Em outras palavras, o novo dicionário deve ficar assim:

                    novo_dicionario = {'b': 4, 'c': 6, 'd': 8, 'f': 12}

                    Utilizando um algoritmo genérico, podemos reslo o problema da seguinte maneira:

                    novo_dicionario = {} for chave, valor in dicionario: if chave in ['b', 'c', 'd', 'f']: novo_dicionario[chave] = 2 * valor print(novo_dicionario) >> {'b': 4, 'c': 6, 'd': 8, 'f': 12}

                    Aplicando agora a abrangência, conseguimos compactar o código acima de maneira interessante:

                    novo_dicionario = {chave: 2 * valor for chave, valor in dicionario.items() if chave in ['b', 'c', 'd', 'f']} Conclusão

                    Chegamos ao final de mais um tutorial! Sempre temos de ter em mente que tão importante quanto escrever um código que funciona, é mantê-lo (seja por você ou por outro programador). Neste ponto, a abrangência de lista (e outras estruturas de dados) nos ajudam a escrever um código claro e fácil de dar manutenção.

                    Até o próximo tutorial pessoal!

                    Publicado originalmente: Abrangencia de listas e dicionários com Python

                    Referências
                    Categories: FLOSS Project Planets

                    Cheppers blog: Development of a sponsored contrib module - Gather Content

                    Planet Drupal - Mon, 2017-01-16 04:52

                    In 2016, our team worked on a sponsored contrib module, GatherContent. The goal of the project was to recreate the module for Drupal 7 using best practices, and to create a brand new module for Drupal 8.

                    Categories: FLOSS Project Planets

                    eGenix.com: Python Meeting Düsseldorf - 2017-01-18

                    Planet Python - Mon, 2017-01-16 04:00

                    The following text is in German, since we're announcing a regional user group meeting in Düsseldorf, Germany.

                    Ankündigung

                    Das nächste Python Meeting Düsseldorf findet an folgendem Termin statt:

                    18.01.2017, 18:00 Uhr
                    Raum 1, 2.OG im Bürgerhaus Stadtteilzentrum Bilk
                    Düsseldorfer Arcaden, Bachstr. 145, 40217 Düsseldorf


                    Neuigkeiten Bereits angemeldete Vorträge

                    Charlie Clark
                            "Kurze Einführung in openpyxl und Pandas"

                    Jochen Wersdörfer
                            "CookieCutter"

                    Marc-Andre Lemburg
                            "Optimierung in Python mit PuLP"

                    Weitere Vorträge können gerne noch angemeldet werden. Bei Interesse, bitte unter info@pyddf.de melden. Startzeit und Ort

                    Wir treffen uns um 18:00 Uhr im Bürgerhaus in den Düsseldorfer Arcaden.

                    Das Bürgerhaus teilt sich den Eingang mit dem Schwimmbad und befindet sich an der Seite der Tiefgarageneinfahrt der Düsseldorfer Arcaden.

                    Über dem Eingang steht ein großes "Schwimm’ in Bilk" Logo. Hinter der Tür direkt links zu den zwei Aufzügen, dann in den 2. Stock hochfahren. Der Eingang zum Raum 1 liegt direkt links, wenn man aus dem Aufzug kommt.

                    >>> Eingang in Google Street View

                    Einleitung

                    Das Python Meeting Düsseldorf ist eine regelmäßige Veranstaltung in Düsseldorf, die sich an Python Begeisterte aus der Region wendet.

                    Einen guten Überblick über die Vorträge bietet unser PyDDF YouTube-Kanal, auf dem wir Videos der Vorträge nach den Meetings veröffentlichen.

                    Veranstaltet wird das Meeting von der eGenix.com GmbH, Langenfeld, in Zusammenarbeit mit Clark Consulting & Research, Düsseldorf:

                    Programm

                    Das Python Meeting Düsseldorf nutzt eine Mischung aus (Lightning) Talks und offener Diskussion.

                    Vorträge können vorher angemeldet werden, oder auch spontan während des Treffens eingebracht werden. Ein Beamer mit XGA Auflösung steht zur Verfügung.

                    (Lightning) Talk Anmeldung bitte formlos per EMail an info@pyddf.de

                    Kostenbeteiligung

                    Das Python Meeting Düsseldorf wird von Python Nutzern für Python Nutzer veranstaltet.

                    Da Tagungsraum, Beamer, Internet und Getränke Kosten produzieren, bitten wir die Teilnehmer um einen Beitrag in Höhe von EUR 10,00 inkl. 19% Mwst. Schüler und Studenten zahlen EUR 5,00 inkl. 19% Mwst.

                    Wir möchten alle Teilnehmer bitten, den Betrag in bar mitzubringen.

                    Anmeldung

                    Da wir nur für ca. 20 Personen Sitzplätze haben, möchten wir bitten, sich per EMail anzumelden. Damit wird keine Verpflichtung eingegangen. Es erleichtert uns allerdings die Planung.

                    Meeting Anmeldung bitte formlos per EMail an info@pyddf.de

                    Weitere Informationen

                    Weitere Informationen finden Sie auf der Webseite des Meetings:

                                  http://pyddf.de/

                    Viel Spaß !

                    Marc-Andre Lemburg, eGenix.com

                    Categories: FLOSS Project Planets

                    Vasudev Ram: Classifying letters and counting their frequencies

                    Planet Python - Sun, 2017-01-15 23:58
                    By Vasudev Ram

                    Here is a program that takes a string as input and classifies the characters in it, into vowels or consonants. It also counts the frequencies of each vowel separately and the frequencies of all consonants together - it is a contrived problem, of course, for teaching purposes.

                    I gave it as an example / exercise for a Python class recently, then modified / enhanced it slightly for this post.

                    It is fairly simple, but happens, partly by chance, to illustrate the use of multiple Python language features in under 35 or so lines of code.
                    I say "partly by chance" because, after writing it initially and then noticing that it used multiple language features, I thought of, and added a few more (for the same program functionality as earlier), trying not to be too artificial or contrived about it :)

                    (The statement that creates the input string s, is of course contrived, but it does manage to illustrate the ''.join(lis) idiom, and string 'multiplication' - and also use of backslash to continue lines, if you can call that a language feature. Also, the string multiplication (as used), though contrived, does allow us to quickly find the frequencies of either vowels or consonants, so it has a use.)

                    Some of the Python language features used are:
                    - dictionary comprehensions (dict comps)
                    - continue statement (beginners sometimes ask what it is used for)
                    - the .get() method of dicts - the 2-argument version, that allows you to avoid an if/else when counting frequencies
                    - returning multiple values from a function
                    - tuple unpacking (of the multiple values returned as a tuple)
                    - the ''.join(lis) idiom to join the characters (or strings) in a list, into a single string
                    - string 'multiplication' by an integer (a shorthand for repeating the string n times)
                    - assert statements for checking post-conditions

                    Here is the program, classify_letters1.py:
                    # classify_letters1.py
                    # Classify input characters as vowels or consonants.
                    # Count frequencies of each vowel.
                    # Count total frequency of all consonants together.
                    # Author: Vasudev Ram
                    # Copyright 2017 Vasudev Ram
                    # Web site: https://vasudevram.github.io
                    # Blog: https://jugad2.blogspot.com
                    # Product store: https://gumroad.com/vasudevram

                    import string

                    VOWELS = 'aeiou'

                    def classify_letters(input):
                    vowel_freqs = { vowel: 0 for vowel in VOWELS }
                    consonants = 0
                    for c in input:
                    if not (c in string.ascii_lowercase):
                    continue
                    if c in VOWELS:
                    vowel_freqs[c] = vowel_freqs.get(c, 0) + 1
                    else:
                    consonants += 1
                    return vowel_freqs, consonants

                    s = ''.join(['a' * 1, 'b' * 1, 'c' * 2, 'd' * 3, 'e' * 2, 'f' * 4, \
                    'g' * 5, 'h' * 6, 'i' * 3, 'j' * 7, 'k' * 8, 'l' * 9, 'm' * 10, \
                    'n' * 11, 'o' * 4, 'p' * 12, 'q' * 13, 'r' * 14, 's' * 15, \
                    't' * 16, 'u' * 5, 'w' * 17, 'y' * 18, 'z' * 19])

                    print "Classifying letters in string:", s
                    print '-' * 70
                    vowel_freqs, consonants = classify_letters(s)
                    print 'vowel freqs:', vowel_freqs
                    print 'consonants total freq:', consonants
                    print '-' * 70
                    print 'Checking results:'
                    assert len(s) == sum(vowel_freqs.values()) + consonants
                    print 'OK'
                    And here is the output on running it:
                    $ py -2 classify_letters1.py
                    Classifying letters in string: abccdddeeffffggggghhhhhhiiijjjjjjjkkkkkkkklllllll
                    llmmmmmmmmmmnnnnnnnnnnnooooppppppppppppqqqqqqqqqqqqqrrrrrrrrrrrrrrssssssssssssss
                    sttttttttttttttttuuuuuwwwwwwwwwwwwwwwwwyyyyyyyyyyyyyyyyyyzzzzzzzzzzzzzzzzzzz
                    ----------------------------------------------------------------------
                    vowel freqs: {'a': 1, 'i': 3, 'e': 2, 'u': 5, 'o': 4}
                    consonants total freq: 190
                    ----------------------------------------------------------------------
                    Checking results:
                    OK
                    I used an assert to do a sanity check of the values computed with the number of letters in the original string.
                    Putting the print 'OK' after the assert has a nice side effect that if the assert does not trigger, the program prints OK, but if it does trigger, it does not print OK, but an error message.

                    - Vasudev Ram - Online Python training and consulting

                    Get updates (via Gumroad) on my forthcoming apps and content.

                    Jump to posts: Python * DLang * xtopdf

                    Subscribe to my blog by email

                    My ActiveState Code recipes

                    Follow me on: LinkedIn * Twitter

                    Managed WordPress Hosting by FlyWheel

                    Share |



                    Vasudev Ram
                    Categories: FLOSS Project Planets

                    Maria Glukhova: APK, images and other stuff.

                    Planet Debian - Sun, 2017-01-15 19:00

                    2 more weeks of my awesome Outreachy journey have passed, so it is time to make an update on my progress.

                    I continued my work on improving diffoscope by fixing bugs and completing wishlist items. These include:

                    Improving APK support

                    I worked on #850501 and #850502 to improve the way diffoscope handles APK files. Thanks to Emanuel Bronshtein for providing clear description on how to reproduce these bugs and ideas on how to fix them.

                    And special thanks to Chris Lamb for insisting on providing tests for these changes! That part actually proved to be little more tricky, and I managed to mess up with these tests (extra thanks to Chris for cleaning up the mess I created). Hope that also means I learned something from my mistakes.

                    Also, I was pleased to see F-droid Verification Server as a sign of F-droid progress on reproducible builds effort - I hope these changes to diffoscope will help them!

                    Adding support for image metadata

                    That came from #849395 - a request was made to compare image metadata along with image content. Diffoscope has support for three types of images: JPEG, MS Windows Icon (*.ico) and PNG. Among these, PNG already had good image metadata support thanks to sng tool, so I worked on .jpeg and .ico files support. I initially tried to use exiftool for extracting metadata, but then I discovered it does not handle .ico files, so I decided to use a bigger force - ImageMagick’s identify - for this task. I was glad to see it had that handy -format option I could use to select only the necessary fields (I found their -verbose, well, too verbose for the task) and presenting them in the defined form, negating the need of filtering its output.

                    What was particulary interesting and important for me in terms of learning: while working on this feature, I discovered that, at the moment, diffoscope could not handle .ico files at all - img2txt tool, that was used for retrieving image content, did not support that type of images. But instead of recognizing this as a bug and resolving it, I started to think of possible workaround, allowing for retrieving image metadata even after retrieving image content failed. Definetely not very good thinking. Thanks Mattia Rizzolo for actually recognizing this as a bug and filing it, and Chris Lamb for fixing it!

                    Other work Order-like differences, part 2

                    In the previous post, I mentioned Lunar’s suggestion to use hashing for finding order-like difference in wide variety of input data. I implemented that idea, but after discussion with my mentor, we decided it is probably not worth it - this change would alter quite a lot of things in core modules of diffoscope, and the gain would be not really significant.

                    Still, implementing that was an important experience for me, as I had to hack on deepest and, arguably, most difficult modules of diffoscope and gained some insight on how they work.

                    Comparing with several tools (work in progress)

                    Although my initial motivation for this idea was flawed (the workaround I mentioned earlier for .ico files), it still might be useful to have a mechanism that would allow to run several commands for finding difference, and then give the output of those that succeed, failing if and only if they all have failed.

                    One possible case when it might happen is when we use commands coming from different tools, and one of them is not installed. It would be nice if we still used the other and not the uninformative binary diff (that is a default fallback option for when something goes wrong with more “clever” comparison). I am still in process of polishing this change, though, and still in doubt if it is needed at all.

                    Side note - Outreachy and my university progress

                    In my Outreachy application, I promised that if I am selected into this round, I will do everything I can to unload the required time period from my university time commitements. I did that by moving most of my courses to the first half of the academic year. Now, the main thing that is left for me to do is my Master’s thesis.

                    I consulted my scientific advisors from both universities that I am formally attending (SFEDU and LUT - I am in double degree program), and as a result, they agreed to change my Master’s thesis topic to match my Outreachy work.

                    Now, that should have sounded like an excellent news - merging these activities together actually mean I can allocate much more time to my work on reproducible builds, even beyond the actual internship time period. That was intended to remove a burden from my shoulders.

                    Still, I feel a bit uneasy. The drawback of this decision lies in fact I have no idea on how to write scientific report based on pure practical work. I know other students from my universities have done such things before, but choosing my own topic means my scientific advisors can’t help me much - this is just out of their area of expertise.

                    Well, wish me luck - I’m up to the challenge!

                    Categories: FLOSS Project Planets

                    Sam Hartman: Musical Visualization of Network Traffic

                    Planet Debian - Sun, 2017-01-15 18:19
                    I've been working on a fun holiday project in my spare time lately. It all started innocently enough. The office construction was nearing its end, and it was time for my workspace to be set up. Our deployment wizard and I were discussing. Normally we stick two high-end monitors on a desk. I'm blind; that seemed silly. He wanted to do something similarly nice for me, so he replaced one of the monitors with excellent speakers. They are a joy to listen to, but I felt like I should actually do something with them. So, I wanted to play around with some sort of audio project.
                    I decided to take a crack at an audio representation of network traffic. The solaris version of ping used to have an audio option, which would produce sound for successful pings. In the past I've used audio queues to monitor events like service health and build status.
                    It seemed like you could produce audio to give an overall feel for what was happening on the network. I was imagining a quick listen would be able to answer questions like:

                    1. How busy is the network

                    2. How many sources are active

                    3. Is the traffic a lot of streams or just a few?

                    4. Are there any interesting events such as packet loss or congestion collapse going on?

                    5. What's the mix of services involved


                    I divided the project into three segments, which I will write about in future entries:

                    • What parts of the network to model

                    • How to present the audio information

                    • Tools and implementation


                    I'm fairly happy with what I have. It doesn't represent all the items above. As an example, it doesn't directly track packet loss or retransmissions, nor does it directly distinguish one service from another. Still, just because of the traffic flow, rsync sounds different from http. It models enough of what I'm looking for that I find it to be a useful tool. And I learned a lot about music and Linux audio. I also got to practice designing discrete-time control functions in ways that brought back the halls of MIT.
                    Categories: FLOSS Project Planets

                    Dirk Eddelbuettel: Rcpp 0.12.9: Next round

                    Planet Debian - Sun, 2017-01-15 17:26

                    Yesterday afternoon, the nineth update in the 0.12.* series of Rcpp made it to the CRAN network for GNU R. Windows binaries have by now been generated; and the package was updated in Debian too. This 0.12.9 release follows the 0.12.0 release from late July, the 0.12.1 release in September, the 0.12.2 release in November, the 0.12.3 release in January, the 0.12.4 release in March, the 0.12.5 release in May, the 0.12.6 release in July, the 0.12.7 release in September, and the 0.12.8 release in November --- making it the thirteenth release at the steady bi-montly release frequency.

                    Rcpp has become the most popular way of enhancing GNU R with C or C++ code. As of today, 906 packages on CRAN depend on Rcpp for making analytical code go faster and further. That is up by sixthythree packages over the two months since the last release -- or about a package a day!

                    Some of the changes in this release are smaller and detail-oriented. We did squash one annoying bug (stemming from the improved exception handling) in Rcpp::stop() that hit a few people. Nathan Russell added a sample() function (similar to the optional one in RcppArmadillo; this required a minor cleanup by for small number of other packages which used both namespaces 'opened'. Date and Datetime objects now have format() methods and << output support. We now have coverage reports via covr as well. Last but not least James "coatless" Balamuta was once more tireless on documentation and API consistency --- see below for more details.

                    Changes in Rcpp version 0.12.9 (2017-01-14)
                    • Changes in Rcpp API:

                      • The exception stack message is now correctly demangled on all compiler versions (Jim Hester in #598)

                      • Date and Datetime object and vector now have format methods and operator<< support (#599).

                      • The size operator in Matrix is explicitly referenced avoiding a g++-6 issues (#607 fixing #605).

                      • The underlying date calculation code was updated (#621, #623).

                      • Addressed improper diagonal fill for non-symmetric matrices (James Balamuta in #622 addressing #619)

                    • Changes in Rcpp Sugar:

                      • Added new Sugar function sample() (Nathan Russell in #610 and #616).

                      • Added new Sugar function Arg() (James Balamuta in #626 addressing #625).

                    • Changes in Rcpp unit tests

                      • Added Environment::find unit tests and an Environment::get(Symbol) test (James Balamuta in #595 addressing issue #594).

                      • Added diagonal matrix fill tests (James Balamuta in #622 addressing #619)

                    • Changes in Rcpp Documentation:

                      • Exposed pointers macros were included in the Rcpp Extending vignette (MathurinD; James Balamuta in #592 addressing #418).

                      • The file Rcpp.bib move to directory bib which is guaranteed to be present (#631).

                    • Changes in Rcpp build system

                      • Travis CI now also calls covr for coverage analysis (Jim Hester in PR #591)

                    Thanks to CRANberries, you can also look at a diff to the previous release. As always, even fuller details are on the Rcpp Changelog page and the Rcpp page which also leads to the downloads page, the browseable doxygen docs and zip files of doxygen output for the standard formats. A local directory has source and documentation too. Questions, comments etc should go to the rcpp-devel mailing list off the R-Forge page.

                    This post by Dirk Eddelbuettel originated on his Thinking inside the box blog. Please report excessive re-aggregation in third-party for-profit settings.

                    Categories: FLOSS Project Planets

                    Mehdi Dogguy: Debian from 10,000 feet

                    Planet Debian - Sun, 2017-01-15 12:12
                    Many of you are big fans of S.W.O.T analysis, I am sure of that! :-) Technical competence is our strongest suit, but we have reached a size and sphere of influence which requires an increase in organisation.

                    We all love our project and want to make sure Debian still shines in the next decades (and centuries!). One way to secure that goal is to identify elements/events/things which could put that goal at risk. To this end, we've organized a short S.W.O.T analysis session at DebConf16. Minutes of the meeting can be found here. I believe it is an interesting read and is useful for Debian old-timers as well as newcomers. It helps to convey a better understanding of the project's status. For each item, we've tried to identify an action.

                    Here are a few things we've worked on:
                    • Identify new potential contributors by attending and speaking at conferences where Free and Open Sources software are still not very well-known, or where we have too few contributors.

                      Each Debian developer is encouraged to identify events where we can promote FOSS and Debian. As DPL, I'd be happy to cover expenses to attend such events.
                    • Our average age is also growing over the years. It is true that we could attract more new contributors than we already do.

                      We can organize short internships. We should not wait for students to come to us. We can get in touch with universities and engineering schools and work together on a list of topics. It is easy and will give us the opportunity to reach out to more students.

                      It is true that we have tried in the past to do that. We may organize a sprint with interested people and share our experience on trying to do internships on Debian-related subjects. If you have successfully done that in the past and managed to attract new contributors that way, please share your experience with us!

                      If you see other ways to attract new contributors, please get in touch so that we can discuss!
                    • Not easy to get started in the project.

                      It could be argued that all the information is available, but rather than being easily findable from on starting point, it is scattered over several places (documentation on our website, wiki, metadata on bug reports, etc…).

                      Fedora and Mozilla both worked on this subject and did build a nice web application to make this easier and nicer. The result of this is asknot-ng.

                      A whatcanidofor.debian.org would be wonderful! Any takers? We can help by providing a virtual machine to build this. Being a DD is not mandatory. Everyone is welcome!
                    • Cloud images for Debian.

                      This is a very important point since cloud providers are now major distributions consumers. We have to ensure that Debian is correctly integrated in the cloud, without making compromises on our values and philosophy.

                      I believe this item has been worked on during the last Debian Cloud sprint. I am looking forward to seeing the positive effects of this sprint in the long term. I believe it does help us to build a stronger relationship with cloud providers and gives us a nice opportunity to work with them on a shared set of goals!
                    During next DebConf, we can review the progress that has been made on each item and discuss new ones. In addition to this session acting as a health check, I see it as a way for the DPL to discuss, openly and publicly, about the important changes that should be implemented in the project and imagine together a better future.

                    In the meantime, everyone should feel free to pick one item from the list and work on it. :-)
                    Categories: FLOSS Project Planets

                    Calligra 3.0 released

                    Planet KDE - Sun, 2017-01-15 09:08

                    A new wonderful era for the Calligra Suite has begun with the release of version 3.0.

                    Support Calligra!

                    We have chosen to cut back on the number of applications. Krita has left us to be independent and although it was emotional it was also done with complete support from both sides. We are saying goodbye to Author, which never differentiated itself from Words. We also removed Braindump the purpose of which will be better fitted by a new application (nothing planned from our side). Flow and Stage has gone in this release but we intend to bring them back in the future. And Kexi has own release schedule but is still part of the Calligra community.

                    What’s New?

                    The 3.x series is built on top of KDE frameworks 5 and Qt5 which in and of itself doesn’t bring much new but it ensures that we stay current. It took a lot of effort which means we haven’t made many other new features.

                    Categories: FLOSS Project Planets

                    FirstAid – PDF Help Viewer

                    Planet KDE - Sun, 2017-01-15 08:18

                    Hi,

                    in the recent months, I didn’t find much time to spend on Kate/KTextEditor development. But at least I was now able to spend a bit more time on OpenSource & Qt things even during work time in our company. Normally I am stuck there with low level binary or source analysis work.

                    For our products, we were in the need of some online help. As our documentation is delivered as PDFs generated by the tools of the TeX Live distro, a natural idea was to use some PDF viewer and integrate it more tightly in our software than just “open the manual at page 1”.

                    We did review PDF viewers out there, but most (like Okular) have too many dependencies to be just bundled with our product (or a license not permitting that).

                    Without bundling, we can’t ensure that the tight coupling is working, without starting to test the integration with X different viewers which more or less all need other kinds of command line arguments to open the right page or even lack that feature or will not reuse an already running instance, ….

                    Therefore, as our GUIs are developed with Qt anyways, we did take a look at libpoppler (and its Qt 5 bindings), which is the base of Okular, too.

                    Easy enough, taking the small demo program shipped with the library and adding a small stdin based interface to tell it “goto <named reference>” we arrived at some small PDF viewer that is fit enough for our use case.

                    We named the thing “FirstAid”, the sources can be grabbed at github.com/AbsInt/FirstAid. Like libpoppler and the demo, its licensed as GPLv2+.

                    As already the README states, the aim of this small project is not to replace some full fledged viewer like Okular, the design goal is to have a small viewer that is auto-started by some host application and will jump to the requested labels for a tightly coupled online help. It can be used as a pure standalone PDF viewer, too, but that is more intended for testing it e.g. on the documents that should later be shown as online help.

                    I already annoyed Albert with some small issue I had with libpoppler, perhaps I will provide more useful fixes in the future if more things come up during FirstAid development. In any case, already THANKS A LOT for the Qt 5 bindings around libpoppler, they work nicely for us!

                    I really think this small project shows the benefit of OpenSource: We needed a PDF viewer, we were able to create a small one in less than a month based on OpenSource libraries and we can give back the results to the community (if it is useful for others is a different story, but perhaps other people have the same itch to scratch, if not, ignore it). I hope more possibilities for such things come up at work in the future.

                    For building: It should build out of the box if you have some recent Qt and libpoppler-qt5-dev installed, at least the Travis CI is able to build it out of the box with the given config. For me, it shows some small bugs if used with Qt 5.6/7 compared to the Qt 5.8 Beta I used here for testing.

                    Categories: FLOSS Project Planets
                    Syndicate content