FLOSS Project Planets

LevelTen Interactive: Drupal Con[densed] 2016: The Best Content Marketing Sessions

Planet Drupal - Wed, 2016-05-18 10:20

As a marketer, a Drupal newbie, and the newest LevelTen employee, I was super excited for DrupalCon.

Historically, there has not been a lot of overlap between the Drupal world and the marketing world. One one level that makes some sense: companies who need a Drupal web solution are often large enterprise-level organizations who have the resources for an in-house marketing team.

But it’s clear after my week at DrupalCon 2016 that more and more agencies and web developers are recognizing that they need to offer some kind of content or content strategy services to their...Read more

Categories: FLOSS Project Planets

LevelTen Interactive: Drupal Con[densed] 2106: The Best Content Marketing Sessions

Planet Drupal - Wed, 2016-05-18 10:20

As a marketer, a Drupal newbie, and the newest LevelTen employee, I was super excited for DrupalCon.

Historically, there has not been a lot of overlap between the Drupal world and the marketing world. One one level that makes some sense: companies who need a Drupal web solution are often large enterprise-level organizations who have the resources for an in-house marketing team.

But it’s clear after my week at DrupalCon 2016 that more and more agencies and web developers are recognizing that they need to offer some kind of content or content strategy services to their...Read more

Categories: FLOSS Project Planets

Jeff Geerling's Blog: Adding a role to a user programmatically in Drupal 8

Planet Drupal - Wed, 2016-05-18 10:18

Since a quick Google search didn't bring up how to do this in Drupal 8 (there are dozens of posts on how to do it in Drupal 7), I thought I'd post a quick blog post on how you can modify a user's roles in Drupal 8. Hint: It's a lot easier than you'd think!

In Drupal 7, $user was an object... but it was more like an object that acted like a dumb storage container. You couldn't really do anything with it directly—instead, you had to stick it in functions (like user_multiple_role_edit()) to do things like add or remove roles or modify account information.

In Drupal 8, $user is a real, useful object. Want to modify the account name and save the change?

Categories: FLOSS Project Planets

OSTraining: Track Google Analytics Clicks and Downloads in Drupal

Planet Drupal - Wed, 2016-05-18 09:58

Over the last week, several people have asked us about tracking Google Analytics "events" on their Drupal site.

"Events" describe anything from clicking on an external link to leave your site or downloading a file.

We're going to use the Google Analytics module which is available for Drupal 6, 7 and 8.

Categories: FLOSS Project Planets

Obey the Testing Goat: Coaches needed for Python Bootcamp @ Pycon US in Portland next week.

Planet Python - Wed, 2016-05-18 09:33

Coming to Pycon? Want to help some beginners to get to grips with Python, and get the most out of the conference? I need your help!

Having observed the surprising number of beginners to be found at Python conferences, I organised a "beginners' day" at last year's EuroPython in Bilbao. We had about 30 beginners attend (from a crowd of 1200 at the conference) -- quite a few science types, some people who already knew another language but wanted to learn Python, and a few total beginners. Everyone seemed to leave with lots of nice things to say about it.

Here's a couple of clips:

I'm running something similar at Pycon this year, on the first day of the tutorials:

Python Bootcamp at Pycon USA 2016, May 28th

The basic idea is shamelessly stolen from the awesome DjangoGirls, and is mainly structured around:

  • self-directed learning based on a selection of Python tutorials (one for total beginners, one for sciencey types, one for web developers, one for programmers who already know another language, and so on)

  • coached by friendly Python developers sitting near each attendee

  • supplemented by a few short lectures on the Python "ecosystem" (what is the cheese shop / the bdfl / a pep / pip / requests / IPython notebook / etc etc)

There's more info in the repo.

I need more coaches! I would love to get to a 3-to-1 ratio of attendees to mentors. You don't have to be an expert Python developer, you just have to be a friendly person, that remembers how tough it can be as a beginner, and that wants to help. I expect quite a few "data science" people in particular, so if you have skills in that area (even if you've only just learned them yourself), I want you!

Check out the DjangoGirls coach manual for a flavour of the kind of attitude I'm trying to cultivate. And don't forget you'll have to swear the "Oath of the Mentor", as per the link above.

Helping beginners is a great feeling, I hope you'll join me! Emails to obeythetestinggoat@gmail.com please :)

PS: This is not a free event for attendees, but I am donating my entire fee for it back to the PSF. Minus, perhaps, a small budget set aside for "thankyou" drinks and cakes for coaches :)

Categories: FLOSS Project Planets

Gary Benson: Full-system Infinity preview coming up

GNU Planet! - Wed, 2016-05-18 09:22

I’ve released bits and pieces of Infinity over the past year, but nothing that really brings everything together. Right now I’m working on an initial full-system release of everything to do with Infinity so far. It’s codenamed “First Flight”, and you’ll be able to actually use it, see how everything hangs together, and generally get a better idea of what the point of it all is.

First Flight will be just enough for GDB to attach to a live process or start with a core file. “info threads” should work, “print errno” will not. First Flight will comprise:

  • A new release of the note compiler I8C.
  • A glibc you can git clone and build to get a libpthread.so with Infinity notes for map_lwp2thr, thr_get_info and thr_iter.
  • A new release of the client library libi8x that can execute those notes.
  • A libthread_db.so shim into libi8x.

The libthread_db.so shim won’t be used in future releases—they’ll have support for Infinity built into GDB—but it’ll likely remain as a nice example of how to use libi8x.

I’m targeting June 23 as the release date for First Flight. You can follow how I’m doing on the Infinity Roadmap (thank you Sergio!)

Categories: FLOSS Project Planets

Pixelite: 10 things I learnt building in Drupal 8

Planet Drupal - Wed, 2016-05-18 08:00
Introduction

I have had the chance to be involved with 2 fresh builds with Drupal 8 now, I thought I would describe some of the neat things I have found during this time and some of my lessons learned. My hope is that blog post will help you in your journey with Drupal 8.

1. Drupal Console is awesome

Every time you need to generate a custom module, or a new block in a custom module, you can quickly and easily use Drupal Console to produce the code scaffolding code for you. This quite easily makes the job of a developer a lot less stressful, and allows you to focus on actually writing code that delivers functionality.

I plucked these example commands that I use frequently from my bash history:

drupal site:mode dev drupal generate:module drupal generate:plugin:block drupal generate:routesubscriber drupal generate:form:config

Documentation is online but for the most part, the commands are self documenting, if you use the --help option, then you get a great summary on the command, and the other options you can pass in.

The other nice thing is that this is a Symfony Console application, so it should feel very familiar to you if you used another tool written in the same framework.

2. Custom block types are amazing

In Drupal 7 land there was bean which was an attempt to stop making ‘meta’ nodes to fill in content editable parts of complex landing pages. Now, fast forward to Drupal 8, and custom block types are now in Drupal Core.

This basically means as a site builder you now have another really powerful tool at your disposal in order to model content effectively in Drupal 8.

Each custom block type can have it’s own fields, it’s own display settings, and form displays.

Here are the final custom block types on a recent Drupal 8 build:

One downside is that there is no access control per custom block type (just a global permission “administer blocks”), no doubt contrib will step in to fill this hole in the future (does anyone know a module that can help here?). In the mean time there is drupal.org issue on the subject.

I also found it weird that the custom blocks administration section was not directly under the ‘structure’ section of the site, there is another drupal.org issue about normalising this as well. Setting up some default shortcuts really helped me save some time.

3. View modes on all the things

To create custom view modes in Drupal 7 required either a custom module or Dave Reid’s entity_view_mode contrib module. Now this is baked into Drupal 8 core.

View modes on your custom block types takes things to yet another level still as well. This is one more feather in the Drupal site builder’s cap.

4. Twig is the best

In Drupal 7 I always found it weird that you could not unleash a front end developer upon your site and expect to have a pleasant result. In order to be successful the themer would need to know PHP, preprocess hooks, template naming standards, the mystical specific order in which the templates apply and so on. This often meant that a backend and front end developer would need to work together in order to create a good outcome.

With the introduction of Twig, I now feel that theming is back in the hands of the front end developer, and knowledge of PHP is no longer needed in order to override just about any markup that Drupal 8 produces.

Pro tip - use the Drupal Console command drupal site:mode dev to enable Twig development options, and disable Drupal caching. Another positive side effect is that Twig will then render the entire list of templates that you could be using, and which one you actually are using (and where that template is located).

Pro tip: - If you want to use a template per custom block type (to which I did), then you can use this PHP snippet in your theme’s .theme file (taken from drupal.org):

<?php /** * Implements hook_theme_suggestions_HOOK_alter() for form templates. * * @param array $suggestions * @param array $variables */ function THEMENAME_theme_suggestions_block_alter(array &$suggestions, array $variables) { if (isset($variables['elements']['content']['#block_content'])) { array_splice($suggestions, 1, 0, 'block__bundle__' . $variables['elements']['content']['#block_content']->bundle()); } } 5. Panelizer + panels IPE is a formidable site building tool

When looking for a layout manager to help build the more complex landing pages, I came across panelizer + panels IPE. Using panelizer you are able to:

  • create per node layout variants
  • apply a single layout to all nodes of a particular bundle (e.g. all your news articles have the same layout)

The other neat thing is that the layouts themselves are now standardised between all the various layout managers using a contrib module called layout_plugin. Also they are just YAML and Twig. Simple. There is even an effort to get this merged into Drupal 8.2 which I think would be a great idea.

Downside - all JS is still rendered on the page even though the user (e.g. anonymous users) have no access to panelizer. There is a patch on drupal.org to help fix this.

Since starting this build there has also been a stable release of display suite come out for Drupal 8 as well giving you even more options.

6. You can build a rather complex site with very little contributed modules

For this most recent site I build I got away with using only 10 contributed modules (one of which - devel was purely for debugging purposes).

  • ctools
  • google_analytics
  • metatag
  • panels
  • token
  • contact_block
  • devel
  • layout_plugin
  • panelizer
  • pathauto

This means you are inherently building a more stable and supportable site, as most of the functionality now comes out of Drupal core.

7. The contact module now is supercharged

In Drupal 7, the contact module was one of those modules to which I never turned on, as it was rather inflexible. You could not change the fields in a UI, nor add email recipients, or have more than 1 form. Now in Drupal 8 you can have as many “contact” forms as you want, each one is fieldable, and can send emails to as many people as needed.

You can also enhance the core module with:

  • contact_block - allows you to place the contact form in a block
  • contact_storage - allows you to store the submissions in the database, rather than firing an email and forgetting about it

There is still a place for webform, namely:

  • large complex form with lots of fields
  • multi-step forms
  • forms you want to ‘save draft’

You can read more about this in the OS training blog post on the contact module.

Downside - I wanted to have a plain page use the path /contact but the contact module registers this path, so pathauto gave my contact page a path of /contact-0. Luckily creating a route subscriber with Drupal Console was painless, so altering the contact module route was very simple to do. I can paste the code here if needed, but most of it is the code that Drupal Console generates for you.

8. PHPunit is bundled into core

Now that Drupal 8 is largely Object Oriented (OO), you are able to test classes using PHPunit. I have wrote about phpunit in the past if you want to know more.

9. Views is in core

This was the main reason why adoption of Drupal 7 was so slow after it’s initial 7.0 release, as everyone needed views to be stable before jumping ship. Now with views bundled into core, views plugins are also being ported at a great rate of knots too.

10. CKEditor is in core

I often found that this was one library that never (or hardly ever) got updated on sites that had been around for a while. More worryingly, CKEditor (the library) would from time to time fix security related issues. Now that this comes with Drupal 8 core, it is just one less thing to worry about.

Also I would love to shout out to Wim Leers (and other contributors) for revamping the image dialog with alignment and caption options. I cannot tell you how much pain and suffering this caused me in Drupal 7.

Comments

If you have built a site recently in Drupal 8 and have found anything interesting or exciting, please let me know in the comments. Also keen to see what sites people have built, so post a link to it if it is public.

Categories: FLOSS Project Planets

Guido van Rossum: Union syntax

Planet Python - Wed, 2016-05-18 07:55
Union syntax(I'm trying to do this as a quick post in response to some questions I received on this topic. I realize this will probably reopen the whole discussion about the best syntax for types, but sorry folks, PEP 484 was accepted nearly a year ago, after many months of discussions and hundreds of messages. It's unlikely that any idea you can think of here would be new. This post just explains the rationale of one particular decision and tries to put it in some context.)I've heard some grumbling about the union syntax in PEP 484: Union[X, Y, Z] (where X, Y and Z are arbitrary type expressions). In the past people have suggested X|Y|Z for this, or (X, Y, Z) or {X, Y, Z}. Why did we go with the admittedly clunkier Union[X, Y, Z]?

First of all, despite all the attention drawn to it, unions are actually a pretty minor feature, and you shouldn't be using them much. So you also shouldn't care that much.
Why not X|Y|Z?This won't fly because we want compatibility with versions of Python 3 that were already frozen (see below). We want to be able to express e.g. a union of int and str, which under this notation would be written as int|str. But for that to fly we'd have to modify the builtin 'type' class to implement __or__ -- and that wouldn't fly on already-frozen Python versions. Supporting X|Y only for types (like List) imported from the typing module and some other notation for builtin types would only sow confusion. So X|Y|Z is out.
Why not {X, Y, Z}?That's the set with elements X, Y and Z, using the builtin set notation. We can usefully consider types to be sets of values, and this makes a union a set of values too (that's why it's called union :-).

However, {X, Y, Z} confuses the set of types with the set of values, which I consider a mortal sin. This would just cause endless confusion.

This notation would also confuse things when taking the union of several classes that overlap, e.g. if we have classes B and C, where C inherits from B, then the union of B and C is just B. But the builtin set doesn't see it that way. In contrast, the X|Y notation could actually solve this (since in principle we could overload __or__ to do whatever we want), and the Union[] operator ("functor"?) from PEP 484 indeed solves this -- in this example Union[B, C] returns the (non-union) type B, both in the type checker and at runtime.
Why not (X, Y, Z)?That's the tuple (X, Y, Z). It has the same disadvantages as {X, Y, Z}, but at least it has the advantage of being similar to how unions are expressed as arguments to isinstance(), for example isinstance(x, (int, str, list)) or isinstance(x, (Sequence, Mapping)). (Similarly the except clause: try: ... / except (KeyError, IndexError): ...)

Another problem with tuples is that the tuple syntax is already overloaded in so many ways that it would be confused with other uses even more easily. One particular confusion would be other generic types, for which we'd still want to use square brackets. (You can't really beat Iterable[int] for clarity if you have an iterable of integers. :-) Suppose you have a sequence of values that could be integers or strings. In PEP 484 notation we write this as Sequence[Union[int, str]]. Using the tuple notation we'd want to write this as Sequence[(int, str)]. But it turns out that the __getitem__ overload on the metaclass can't tell the difference between Sequence[(int, str)] and Sequence[int, str] -- and we would like to reject the latter as a mistake since Sequence[] is a generic class over a single parameter. (An example of a generic class over two parameters would be Mapping[K, V].) Disambiguating all this would place us on very thin ice indeed.

The nail in this idea's coffin is the competing idea of using (X, Y, Z) to indicate a tuple with three items, with respective types, X, Y and Z. At first sight this seems an even better use of the tuple syntax than unions would be, and tuples are way more common than unions. But it runs afoul of the same problems with Foo[(X, Y)] vs. Foo[X, Y]. (Also, there would be no easy way to describe what PEP 484 calls Tuple[X, ...], i.e. a variable-length tuple with uniform item type X.)
PS. Why support old Python 3 versions?The reason for supporting older versions is adoption. Only a relatively small crowd of early adopters can upgrade to the latest Python version as soon as it's out; the rest of us are stuck on older versions (even Python 2.7!).

So for PEP 484 and the typing module, we wanted to support 3.2 and up -- we chose 3.2 because it's the newest Python 3 supported by some older but still popular Ubuntu and Debian distributions. (Also, 3.0 and 3.1 were too immature at their time of release to ever have a large following.)

There's a typing package that you can install easily using pip, and this defines all sorts of useful things for typing, from Any and Union to generic versions of List and Sequence. But such a package can't modify existing builtins like int or list.

(Eventually we also added Python 2.7 support, using type comments for function signatures.)
Categories: FLOSS Project Planets

IXIS: British Council win RealIT Award 2016 for Infrastructure as an Enabler

Planet Drupal - Wed, 2016-05-18 07:10

Members of the British Council Digital team were delighted to receive the RITA2016 award last Thursday for the huge change in IT cloud infrastructure that Ixis delivered in the summer of 2015.

read more

Categories: FLOSS Project Planets

Radium on Drupal: My road to Drupal and GSoC

Planet Drupal - Wed, 2016-05-18 07:02
I am very happy that my GSoC project, Web Component-ize Drupal 8, got accepted this year. I would like to say thanks to my mentors skyredwang and wimleers, as well as all the members of the community who are supportive of the Google Summer of Code program, in particular Slurpee who has spent a lot of time coordinating and helping students.
Categories: FLOSS Project Planets

Hello! Let's start with CLion

Planet KDE - Wed, 2016-05-18 06:58

Hello! My name is Vladyslav Batyrenko, I’m a student living in Kyiv, Ukraine. This is my first GSoC blog post about my participating in Ark project. In this post I would like to tell you how I managed to set up my environment for coding with CLion, utilizing it not only as an editor but also as a debugging tool. You may think that’s a trivial task almost every IDE can handle - and this is true, but until your project requires a non-trivial deployment process before it is able to start. So if you want to know how to build, deploy and run/debug your executable with pressing only (SHIFT+F10) buttons, you may find this post useful.

Categories: FLOSS Project Planets

Twisted Matrix Labs: Twisted 16.2 Released

Planet Python - Wed, 2016-05-18 06:10
On behalf of Twisted Matrix Laboratories, I am honoured to announce the release of Twisted 16.2!

Just in time for PyCon US, this release brings a few headlining features (like the haproxy endpoint) and the continuation of the modernisation of the codebase. More Python 3, less deprecated code, what's not to like?
  • twisted.protocols.haproxy.proxyEndpoint, a wrapper endpoint that gives some extra information to the wrapped protocols passed by haproxy;
  • Migration of twistd and other twisted.application.app users to the new logging system (twisted.logger);
  • Porting of parts of Twisted Names' server to Python 3;
  • The removal of the very old MSN client code and the deprecation of the unmaintained ICQ/OSCAR client code;
  • More cleanups in Conch in preparation for a Python 3 port and cleanups in HTTP code in preparation for HTTP/2 support;
  • Over thirty tickets overall closed since 16.1.
For more information, check the NEWS file (link provided below).

You can find the downloads on PyPI (or alternatively our website). The NEWS file is also available on GitHub.

Many thanks to everyone who had a part in this release - the supporters of the Twisted Software Foundation, the developers who contributed code as well as documentation, and all the people building great things with Twisted!

Twisted Regards,
Amber Brown (HawkOwl)
Categories: FLOSS Project Planets

IXIS: When Poor Security Practices Go Bad

Planet Drupal - Wed, 2016-05-18 05:27

In this blog post I'll discuss some methods of ensuring that your software is kept up to date, and some recent examples of why you should consider security to be among your top priorities instead of viewing it as an inconvenience or hassle.

Critics often attack the stability and security of Open Source due to the frequent releases and updates as projects evolve through constant contributions to their code from the community. They claim that open source requires too many patches to stay secure, and too much maintenance as a result.

read more

Categories: FLOSS Project Planets

Drop Guard: Top 5 sessions of DrupalCon New Orleans (security and maintenance related)

Planet Drupal - Wed, 2016-05-18 05:03
Top 5 sessions of DrupalCon New Orleans (security and maintenance related) Igor Kandyba Wed, 18.05.2016 - 11:03

Drop Guard team didn't make it to DC North America this year, but we've spent quite a time talking to our colleagues there, interacting with people via Twitter and Facebook, and obviously - enjoying the sessions as soon as they're available for the online viewing.

We are really excited about the number of the highest quality sessions on various topics, and to be honest we recommend to watch all of them (although be aware of the time you need to complete the whole list).

However, for those interested in all things security, support and maintenance related, and not having too much time to enjoy the full playlist, we've hand-picked a limited amount of videos which we found most insightful and would recommend to the Drop Guard blog readers.

Drupalcon video Drupal Planet
Categories: FLOSS Project Planets

Python Anywhere: Today's upgrade - postgres price drop, mysql scaling improvements

Planet Python - Wed, 2016-05-18 04:50

Nothing earth-shattering to report today, but some good news:

Postgres is cheaper

It's been over a year since we first tentatively launched our postgres service, and we've found that we're able to optimise the service so that it scales better than we thought, so we're pleased to pass on the cost savings to you.

Postgres is now $7/month instead of $15. That price will apply to all new plans and upgrades, and we'll also start applying the new price to existing users for their next bill. So that more moolah in your pockets dear users, don't spend it all at once ;)

MySQL infrastructure changes

These changes won't really be very visible from the user point of view, so this isn't very interesting to you, beloved readers, per se, but it took us loads of time and effort so we have to say something to make it all feel worthwhile and satisfy our own egos. Anyways, we made some changes to the way we shard users amongst MySQL servers in our clusters, which mean it's now much easier for us to add extra MySQL capacity whenever we want to.

For the curious, did you know that (depending on your OS and config), filesystem limits on the number of hard links in a single directory might limit you to a maximum of 32,000 databases on a single mysql instance? Not that we ever came anywhere near that, but still, good to know. #tipsforpaasproviders.

Python.org console now Python 3.5

Our live consoles on the python.org front page are now Python 3.5 instead of 3.4. We've also made them "regular" Python consoles instead of IPython (which was always a slightly weird decision, even though IPython is all awesome and everything, but a regular Python console is what new users are most likely to see, and ours do have tab-completion switched on you know?)

Onwards and upwards folks! In our next iteration we hope to be able to release a first beta of an API for PythonAnywhere. Watch this space :)

Categories: FLOSS Project Planets

Guido van Rossum: Adding type annotations for fspath

Planet Python - Wed, 2016-05-18 04:39
Type annotations for fspathPython 3.6 will have a new dunder protocol, __fspath__() , which should be supported by classes that represent filesystem paths. Example of such classes are the pathlib.Path family and os.DirEntry  (returned by os.scandir() ).
You can read more about this protocol in the brand new PEP 519. In this blog post I’m going to discuss how we would add type annotations for these additions to the standard library.
I’m making frequent use of AnyStr , a quite magical type variable predefined in the typing module. If you’re not familiar with it, I recommend reading my blog post about AnyStr . You may also want to read up on generics in PEP 484 (or read mypy’s docs on the subject).Adding os.scandir() to the stubs for os.pyFor practice, let’s see if we can add something to the stub file for os.py. As of this writing there’s no typeshed information for os.scandir() , which I think is a shame. I think the following will do nicely. Note how we only define DirEntry  and scandir() for Python versions >= 3.5. (Mypy doesn’t support this yet, but it will soon, and the example here still works — it just doesn’t realize scandir()  is only available in Python 3.5.) This could be added to the end of stdlib/3/os/__init__.pyi:
from typing import Generic, AnyStr, overload, Iterator
if sys.version_info >= (3, 5):
    class DirEntry(Generic[AnyStr]):        name = ...  # type: AnyStr        path = ...  # type: AnyStr        def inode(self) -> int: ...        def is_dir(self, *, follow_symlinks: bool = ...) -> bool: ...        def is_file(self, *, follow_symlinks: bool = ...) -> bool: ...        def is_symlink(self) -> bool: ...        def stat(self, *, follow_symlinks: bool = ...) -> stat_result: ...
    @overload    def scandir() -> Iterator[DirEntry[str]]: ...    @overload    def scandir(path: AnyStr) -> Iterator[DirEntry[AnyStr]]: ...
Deconstructing this a bit, we see a generic class (that’s what the Generic[AnyStr]  base class means) and an overloaded function.  The scandir() definition uses @overload because it can also be called without arguments. We could also write it as follows; it’ll work either way:
    @overload    def scandir(path: str = ...) -> Iterator[DirEntry[str]]: ...    @overload    def scandir(path: bytes) -> Iterator[DirEntry[bytes]]: ...
Either way there really are three ways to call scandir() , all three returning an iterable of DirEntry objects:
  • scandir() -> Iterator[DirEntry[str]] 
  • scandir(str) -> Iterator[DirEntry[str]] 
  • scandir(bytes) -> Iterator[DirEntry[bytes]] 
Adding os.fspath()Next I’ll show how to add os.fspath() and how to add support for the __fspath__()  protocol to DirEntry .
PEP 519 defines a simple ABC (abstract base class), PathLike , with one method, __fspath__() . We need to add this to the stub for os.py , as follows:
class PathLike(Generic[AnyStr]):    @abstractmethod    def __fspath__(self) -> AnyStr: ...
That’s really all there is to it (except for the sys.version_info  check, which I’ll leave out here since it doesn’t really work yet). Next we define os.fspath() , which wraps this protocol. It’s slightly more complicated than just calling its argument’s __fspath__()  method, because it also handles strings and bytes. So here it is:
@overloaddef fspath(path: PathLike[AnyStr]) -> AnyStr: ...@overloaddef fspath(path: AnyStr) -> AnyStr: ...
Easy enough! Next is update the definition of DirEntry . That’s easy too — in fact we only need to make it inherit from PathLike[AnyStr] , the rest is the same as the definition I gave above:
class DirEntry(PathLike[AnyStr], Generic[AnyStr]):    # Everything else unchanged!
The only slightly complicated bit here is the extra base class Generic[AnyStr] . This seems redundant, and in fact PEP 484 says we can leave it off, but mypy doesn’t support that yet, and it’s quite harmless — this just rubs into mypy’s face that this is a generic class of one type variable (the by-now famous AnyStr ).
Finally we need to make a similar change to the stub for pathlib.py . Again, all we need to do is to make PurePath  inherit from PathLike[str] , like so:
from os import PathLike
class PurePath(PathLike[str]):    # Everything else unchanged!
However, here we don’t add Generic , because this is not a generic class! It inherits from PathLike[str] , which is quite un-generic, since it’s PathLike specialized for just str .
Note that we don’t actually have to define the __fspath__()  method in these stubs — we’re not supposed to call them directly, and stubs don’t provide implementations, only interfaces.
Putting it all together, we see that it’s quite elegant:
for a in os.scandir('.'):    b = os.fspath(a)    # Here, the typechecker will know that the type of b is str!
The derivation that b has type str  is not too complicated: first, os.scandir('.')  has a str  argument, so it returns an iterator of DirEntry  objects parameterized with str , which we write as DirEntry[str] . Passing this DirEntry[str]  to os.fspath()  then takes the first of that function’s two overloads (the one with PathLike[AnyStr] ), since it doesn’t match the second one ( DirEntry  doesn’t inherit from AnyStr , because it’s neither a str  nor bytes ). Further the AnyStr type variable in PathLike[AnyStr] is solved to stand for just str , because DirEntry[str]  inherits from PathLike[str] . This is the specialized version of what the code says: DirEntry[AnyStr]  inherits from PathLike[AnyStr] .
Okay, so maybe that last paragraph was intermediate or advanced. And maybe it could be expanded. Maybe I’ll write another blog about how type inference works, but there’s a lot on that topic, and other authors have probably already written better introductory material about generics (in other languages, though).Making things accept PathLikeThere’s a bit of cleanup work that I’ve left out. PEP 519 says that many stdlib functions that currently take strings for pathnames will be modified to also accept PathLike . For example, here’s how the signatures for os.scandir()  would change:
@overloaddef scandir() -> Iterator[DirEntry[str]]: ...@overloaddef scandir(path: AnyStr) -> Iterator[DirEntry[AnyStr]]: ...@overloaddef scandir(path: PathLike[AnyStr]) -> Iterator[DirEntry[AnyStr]]: ...
The first two entries are unchanged; I’ve just added a third overload. (Note that the alternative way of defining scandir() would require more changes — an indication that this way is more natural.)
I also tried doing this with a union:
@overloaddef scandir() -> Iterator[DirEntry[str]]: ...@overloaddef scandir(path: Union[AnyStr, PathLike[AnyStr]]) -> Iterator[DirEntry[AnyStr]]: ...
But I couldn’t get this to work, so the extra overload is probably the best we can do. Quite a few functions will require a similar treatment, sometimes introducing overloading where none exists today (but that shouldn’t hurt anything).
A note about pathlib : since it only deals with strings, its methods (the ones that PEP 519 says should be changed anyway) should use PathLike[str]  rather than PathLike[AnyStr] .Acknowledgments(Thanks for comments on the draft to Stephen Turnbull, Koos Zevenhoven, Ethan Furman, and Brett Cannon.)
Categories: FLOSS Project Planets

Talk Python to Me: #59 SageMath - Open source is ready to compete in the classroom

Planet Python - Wed, 2016-05-18 04:00
What do you do when you are a high caliber mathematician or scientist and you want share your algorithms and code? This sounds like a job for github, but the problem is often this work is done on proprietary platforms such as Magma, Matlab, Mathematica or others. <br/> <br/> Not only can you not share your licenses for say, Matlab, but there are often proprietary separate libraries and tools for specialized work. These are expensive products. One example from my distant past was using the Wavelet toolbox on Matlab. Matlab is 2,000 euros and the wavelet library is another 1,000 euros! So to share my code, you must have both licenses for yourself. This is a problem. <br/> <br/> Well, if you're William Stein you take this problem and turn it into an opportunity to build an open source competitor to Matlab and related platforms. This episode is all about SageMath, an open source, feature rich option for scientists and mathematicians built by over 500 contributors and consisting of over 500k lines of Python and Cython code.
Categories: FLOSS Project Planets

Bits from Debian: Imagination accelerates Debian development for 64-bit MIPS CPUs

Planet Debian - Wed, 2016-05-18 03:30

Imagination Technologies recently donated several high-performance SDNA-7130 appliances to the Debian Project for the development and maintenance of the MIPS ports.

The SDNA-7130 (Software Defined Network Appliance) platforms are developed by Rhino Labs, a leading provider of high-performance data security, networking, and data infrastructure solutions.

With these new devices, the Debian project will have access to a wide range of 32- and 64-bit MIPS-based platforms.

Debian MIPS ports are also possible thanks to donations from the aql hosting service provider, the Eaton remote controlled ePDU, and many other individual members of the Debian community.

The Debian project would like to thank Imagination, Rhino Labs and aql for this coordinated donation.

More details about GNU/Linux for MIPS CPUs can be found in the related press release at Imagination and their community site about MIPS.

Categories: FLOSS Project Planets

Krita 3.0 Release Candidate 1 Released

Planet KDE - Wed, 2016-05-18 02:26

We’re getting closer and closer to releasing Krita 3.0, the first version of Krita that includes animation tools, instant preview and which is based on Qt5! Today’s release candidate offers many fixes and improvements over the previous beta releases. The Animation and Instant Preview features were funded by last year’s successful Kickstarter, and right now we’re running our third Kickstarter campaign: this year’s main topics are creating a great text and vector toolset. After one week, we’re already half-way!

The biggest new feature is no doubt support for hand-drawn animation. This summer, Jouni Pentikäinen will continue improving the animation tools, but it’s already a solid toolset. Here’s a video tutorial where Wolthera shows how she created the animated headers for this year’s Kickstarter stretch goals:

And here is another demonstration by Wolthera showing off the Instant Preview feature, which makes it possible to use big brushes on big canvases. It may take a bit more memory, but it gives a huge speed boost:

Apart from Instant Preview, Animation, Qt5-support, Krita 3.0 will have a number of Kickstarter stretch goals, like improved layer handling, improved shortcuts, the tangent normal brush, and great colorspace selector, guides, a grids and guides docker, snapping to grids and guides, improved shortcut palette, gradient map filter and much, much, much more. And we’ll be sure to fix more issues before we present the final release.

So check out the review prepared by Nathan Lovato, while we’re preparing the full release announcement:

Release Candidate 3 Improvements

Compared to the last beta, we’ve got the following improvements:

  • Shortcuts now also work if the cursor is not hovering over the canvas
  • Translations are more complete
  • The export to PDF dialog shows the page preview
  • The advanced color selector is faster
  • The vector gradient tool performs petter
  • Fill layers are saved and loaded correctly
  • Improvements to Instant Preview
  • Fix crashes when setting font properties in the text tool.
  • Fix handling the mirror axis handle
  • Use OpenMP in G’Mic on Windows and Linux, which makes most filters much faster
  • Fixes to the file dialog
  • The Spriter export plugin was rewritten
  • Fix a number of crashes
  • Fix the scaling of the toolbox icons
  • Add new icons for the pan and zoom tools
  • Make it possible to enable HiDPI mode by setting the environment variable KRITA_HIDPI to ON.
  • Fix the fade, distance and time sensors in the brush editor
  • Make it possible to open color palettes again
  • Add a shortcut for toggling onion skinning
  • Fix loading of the onion skin button states
  • Add a lock for the brush drawing angle
  • Handle positioning popups and dialogs on multi-monitor setups correctly

And a load of smaller things!

Downloads

Windows Shell Extension package by Alvin Wong. Just install it and Windows Explorer will start showing preview and meta information for Krita files. (Disregard any warnings by virus checkers, because this package is built with the NSIS installer maker, some virus checkers always think it’s infected, it’s not.)

Windows: Unzip and run the bin/krita.exe executable! These downloads do not interfere with your existing installation. The configuration file location has been moved from %APPDATA%\Local\kritarc to %APPDATA%\Local\krita\kritarc.

The OSX disk image still has the known issue that if OpenGL is enabled, the brush outline cursor, grids, guides and so on are not visible. We’re working on that, but don’t expect to have rewritten the canvas before 3.0 will be released. Disable OpenGL in the preferences dialog to see a cursor outline, grids and guides and so on.

The Linux appimage:After downloading, make the appimage executable and run it. No installation is needed. For CentOS 6 and Ubuntu 12.04, a separate appimage is provided with g’mic built without OpenMP (which makes it much slower)

As usual, you can use these builds without affecting your 2.9 installation.

Source: you can find the source here:

Categories: FLOSS Project Planets

Montreal Python User Group: Meals-on-wheel Hacknight

Planet Python - Wed, 2016-05-18 00:00

Join us on May 26th and contribute to new management platform of Santropol Roulant. They need our help to get a better tools to manage and deliver food to people with disabilities and difficulties.

This platform will be at the heart of their service and it's entirely based on Django. The project needs volunteers who would like give a hand and to contribute their open platform and pursue it's development.

It's your opportunity to achieves some tasks of the project (https://github.com/savoirfairelinux/santropol-feast), and to get to know what people of Santropol are doing. Please note that the event is targeting people who are used to Django but not necessarily experts with it, don't be afraid and join us :)

People from Santropol will prepare food that will be serve to the volunteers of the event!

This Free software project was also built by Savoir-Faire Linux and volunteers from la Maison du logiciel Libre.

Please note that the event will be bilingual.

When

Thursday, May 26th, starting at 5:30pm

Where

Santropol Roulant 111 Roy East (Sherbrooke metro) https://goo.gl/maps/GjkC9DSj9m92

Categories: FLOSS Project Planets
Syndicate content